plasma-framework/scriptengines/javascript/tests/script-nowplaying/contents/code/main.js
Marco Martin 35a255722e an embryo of Service access
svn path=/trunk/KDE/kdebase/workspace/plasma/scriptengines/javascript/; revision=906206
2009-01-05 19:16:44 +00:00

38 lines
1011 B
JavaScript

engine = dataEngine("nowplaying");
players = engine.sources;
watchingPlayer = players[0];
controller = engine.serviceForSource(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 = engine.serviceForSource(watchingPlayer).operationDescription("stop");
print(data+controller.name());
for ( var i in data ) {
print(i + ' -> ' + data[i] );
}
controller.startOperationCall(controller.operationDescription("stop"));
print("stopping");
}
layout = new LinearLayout(plasmoid);
layout.orientation = Vertical;
label = new Label();
layout.addItem(label);
stop = new PushButton();
stop.text = "Stop";
layout.addItem(stop);
controller.associateWidget(stop, "stop");
print(controller.operationNames());
stop["clicked()"].connect(plasmoid.stop);
engine.connectSource(watchingPlayer, plasmoid, 500);