2009-01-05 20:16:44 +01:00
|
|
|
engine = dataEngine("nowplaying");
|
|
|
|
players = engine.sources;
|
|
|
|
watchingPlayer = players[0];
|
2009-01-05 21:49:26 +01:00
|
|
|
controller = service("nowplaying", watchingPlayer);
|
2009-01-05 20:16:44 +01:00
|
|
|
|
2009-01-05 13:53:01 +01:00
|
|
|
plasmoid.dataUpdate = function(a, b)
|
|
|
|
{
|
|
|
|
label.text = "Playing " + b.Title + " by " + b.Artist + ". time: " +
|
2009-01-05 23:44:21 +01:00
|
|
|
Math.floor(b.Position/60) + ":" + (parseInt(b.Position)%60);
|
|
|
|
progress.value = 100*b.Position/b.Length;
|
2009-01-05 13:53:01 +01:00
|
|
|
}
|
|
|
|
|
2009-01-05 13:58:05 +01:00
|
|
|
plasmoid.stop = function()
|
|
|
|
{
|
2009-01-05 21:53:39 +01:00
|
|
|
data = controller.operationDescription("stop");
|
2009-01-05 22:52:23 +01:00
|
|
|
print(controller.name());
|
2009-01-05 20:16:44 +01:00
|
|
|
for ( var i in data ) {
|
|
|
|
print(i + ' -> ' + data[i] );
|
|
|
|
}
|
|
|
|
|
|
|
|
controller.startOperationCall(controller.operationDescription("stop"));
|
2009-01-05 13:58:05 +01:00
|
|
|
print("stopping");
|
|
|
|
}
|
|
|
|
|
2009-01-05 22:52:23 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2009-01-05 13:53:01 +01:00
|
|
|
layout = new LinearLayout(plasmoid);
|
2009-01-05 23:30:30 +01:00
|
|
|
layout.setOrientation(QtVertical);
|
2009-01-05 13:53:01 +01:00
|
|
|
label = new Label();
|
|
|
|
layout.addItem(label);
|
|
|
|
|
2009-01-05 13:58:05 +01:00
|
|
|
stop = new PushButton();
|
|
|
|
stop.text = "Stop";
|
|
|
|
layout.addItem(stop);
|
|
|
|
|
2009-01-05 20:16:44 +01:00
|
|
|
controller.associateWidget(stop, "stop");
|
|
|
|
|
2009-01-05 13:58:05 +01:00
|
|
|
stop["clicked()"].connect(plasmoid.stop);
|
|
|
|
|
2009-01-05 22:52:23 +01:00
|
|
|
progress = new Slider();
|
2009-01-05 23:30:30 +01:00
|
|
|
progress.orientation = QtHorizontal;
|
2009-01-05 22:52:23 +01:00
|
|
|
layout.addItem(progress);
|
|
|
|
controller.associateWidget(progress, "progress");
|
|
|
|
|
2009-01-05 23:44:21 +01:00
|
|
|
progress["sliderMoved(int)"].connect(plasmoid.setProgress);
|
2009-01-05 22:52:23 +01:00
|
|
|
|
2009-01-05 21:49:26 +01:00
|
|
|
engine.connectSource(watchingPlayer, plasmoid, 500);
|