Changeset View
Changeset View
Standalone View
Standalone View
applets/mediacontroller/contents/ui/main.qml
Show First 20 Lines • Show All 242 Lines • ▼ Show 20 Line(s) | 28 | Item { | |||
---|---|---|---|---|---|
243 | function action_next() { | 243 | function action_next() { | ||
244 | serviceOp(mpris2Source.current, "Next"); | 244 | serviceOp(mpris2Source.current, "Next"); | ||
245 | } | 245 | } | ||
246 | 246 | | |||
247 | function action_stop() { | 247 | function action_stop() { | ||
248 | serviceOp(mpris2Source.current, "Stop"); | 248 | serviceOp(mpris2Source.current, "Stop"); | ||
249 | } | 249 | } | ||
250 | 250 | | |||
251 | function action_walk_through() { | ||||
252 | if (mpris2Source.sources.length < 3) { | ||||
ngraham: Why wouldn't you want to be able to do this when there are two sources? | |||||
mpris2Source.sources always has at least one value, that value being "@multiplex". Because of this it will have a length of 3 when there are two audio sources, a length of 4 when there are three, etc. Perhaps I should include a comment to clarify and avoid this confusion. dylanmcdougall: mpris2Source.sources always has at least one value, that value being "@multiplex". Because of… | |||||
253 | return | ||||
254 | } | ||||
255 | | ||||
256 | // Find the index of the current source | ||||
257 | for (var i = 0, length = mpris2Source.sources.length; i < length; ++i) { | ||||
258 | if (mpris2Source.sources[i] === mpris2Source.current) { | ||||
259 | while (mpris2Source.sources[(i + 1) % mpris2Source.sources.length] === mpris2Source.multiplexSource) { | ||||
260 | ++i // Find the next source that isn't multiplexSource | ||||
261 | } | ||||
262 | mpris2Source.current = mpris2Source.sources[(i + 1) % mpris2Source.sources.length] | ||||
263 | break | ||||
264 | } | ||||
265 | } | ||||
266 | } | ||||
267 | | ||||
251 | function serviceOp(src, op) { | 268 | function serviceOp(src, op) { | ||
252 | var service = mpris2Source.serviceForSource(src); | 269 | var service = mpris2Source.serviceForSource(src); | ||
253 | var operation = service.operationDescription(op); | 270 | var operation = service.operationDescription(op); | ||
254 | return service.startOperationCall(operation); | 271 | return service.startOperationCall(operation); | ||
255 | } | 272 | } | ||
256 | 273 | | |||
257 | states: [ | 274 | states: [ | ||
258 | State { | 275 | State { | ||
Show All 23 Lines |
Why wouldn't you want to be able to do this when there are two sources?