8ddb49f755
update slider position in dataUpdate svn path=/trunk/KDE/kdebase/workspace/plasma/scriptengines/javascript/; revision=906312
58 lines
1.5 KiB
JavaScript
58 lines
1.5 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(parseInt(b.Position)/60) + ":" + (parseInt(b.Position)%60);
|
|
progress.value = b.Position;
|
|
}
|
|
|
|
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(QtVertical);
|
|
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 = QtHorizontal;
|
|
layout.addItem(progress);
|
|
controller.associateWidget(progress, "progress");
|
|
|
|
progress["valueChanged(int)"].connect(plasmoid.setProgress);
|
|
|
|
engine.connectSource(watchingPlayer, plasmoid, 500);
|