1 // set up the engine, player and controller
2 engine = dataEngine("nowplaying");
3 watchingPlayer = engine.sources[0];
4 controller = service("nowplaying", watchingPlayer);
6 // define a few functions
7 plasmoid.dataUpdate = function(a, b)
9 label.text = "Playing " + b.Title + " by " + b.Artist + ". time: " +
10 Math.floor(b.Position/60) + ":" + (parseInt(b.Position)%60);
11 progress.value = 100*b.Position/b.Length;
14 plasmoid.stop = function()
16 data = controller.operationDescription("stop");
17 print(controller.name());
18 for ( var i in data ) {
19 print(i + ' -> ' + data[i] );
22 controller.startOperationCall(controller.operationDescription("stop"));
26 plasmoid.setProgress = function(progress)
28 operation = controller.operationDescription("seek");
29 operation.seconds = progress;
30 for ( var i in operation ) {
31 print(i + ' -> ' + operation[i] );
34 controller.startOperationCall(operation);
35 print("set progress to " + progress);
39 layout = new LinearLayout(plasmoid);
40 layout.setOrientation(QtVertical);
42 layout.addItem(label);
44 stop = new PushButton();
48 progress = new Slider();
49 progress.orientation = QtHorizontal;
50 layout.addItem(progress);
52 // Glue things together
53 stop.clicked.connect(plasmoid.stop);
54 progress.sliderMoved.connect(plasmoid.setProgress);
56 controller.associateWidget(stop, "stop");
57 controller.associateWidget(progress, "progress");
59 engine.connectSource(watchingPlayer, plasmoid, 500);