Marco Martin 8040abf0b9 now service -really- works.
to attest that, beginnings of a progress slider to control the elapsed
song time, and seems to not be possible to put it horizontal, that's the
next problem

svn path=/trunk/KDE/kdebase/workspace/plasma/scriptengines/javascript/; revision=906299
2009-01-05 21:52:23 +00:00

57 lines
1.4 KiB
JavaScript

engine = dataEngine("nowplaying");
players = engine.sources;
watchingPlayer = players[0];
controller = service("nowplaying", watchingPlayer);
plasmoid.dataUpdate = function(a, b)
{
label.text = "Playing " + b.Title + " by " + b.Artist + ". time: " +
parseInt(b.Position/60) + ":" + (parseInt(b.Position)%60);
}
plasmoid.stop = function()
{
data = controller.operationDescription("stop");
print(controller.name());
for ( var i in data ) {
print(i + ' -> ' + data[i] );
}
controller.startOperationCall(controller.operationDescription("stop"));
print("stopping");
}
plasmoid.setProgress = function(progress)
{
operation = controller.operationDescription("seek");
operation["seconds"] = progress;
for ( var i in operation ) {
print(i + ' -> ' + operation[i] );
}
controller.startOperationCall(operation);
print("set progress to " + progress);
}
layout = new LinearLayout(plasmoid);
layout.setOrientation(Vertical);
label = new Label();
layout.addItem(label);
stop = new PushButton();
stop.text = "Stop";
layout.addItem(stop);
controller.associateWidget(stop, "stop");
stop["clicked()"].connect(plasmoid.stop);
progress = new Slider();
progress.orientation = Horizontal;
layout.addItem(progress);
controller.associateWidget(progress, "progress");
progress["valueChanged(int)"].connect(plasmoid.setProgress);
engine.connectSource(watchingPlayer, plasmoid, 500);