summaryrefslogtreecommitdiffstats
path: root/app/api
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2017-05-25 16:52:13 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2017-06-02 22:28:18 -0700
commitf3ddc376291262a6b305cc2b0a52792abdc7c85c (patch)
tree5e2685d2f62690e32ee8b4920e8dd139bab322d1 /app/api
parentb0f682b1579e520896ccd5492d6666d962a0c226 (diff)
binding: remove non-binding lightmediascanner detection
Switch to binding over raw DBus commands for media detection. Bug-AGL: SPEC-610 Change-Id: Icf924000d721d92a1056962e55f5c2c75f159ee5 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'app/api')
-rw-r--r--app/api/LightMediaScanner.qml40
1 files changed, 28 insertions, 12 deletions
diff --git a/app/api/LightMediaScanner.qml b/app/api/LightMediaScanner.qml
index 1fe2f25..d0b7137 100644
--- a/app/api/LightMediaScanner.qml
+++ b/app/api/LightMediaScanner.qml
@@ -43,21 +43,30 @@ WebSocket {
console.debug("response: " + JSON.stringify(response))
switch (json[0]) {
case msgid.call:
- break
+ break
case msgid.retok:
- root.statusString = request.status
- var verb = verbs.shift()
- if (verb == "media_added") {
- console.debug("Media is inserted")
- } else if (verb == "media_removed") {
- console.debug("Media is removed")
- }
- break
+ root.statusString = request.status
+ var verb = verbs.shift()
+ if (verb == "media_result") {
+ console.debug("Media result returned")
+ playlist.addItems(response.Media)
+ }
+ break
case msgid.reterr:
- root.statusString = "Bad return value, binding probably not installed"
- break
+ root.statusString = "Bad return value, binding probably not installed"
+ break
case msgid.event:
- break
+ var payload = JSON.parse(JSON.stringify(json[2]))
+ var event = payload.event
+ if (event == "media-manager/media_added") {
+ console.debug("Media is inserted")
+ playlist.addItems(json[2].data.Media)
+ } else if (event == "media-manager/media_removed") {
+ console.debug("Media is removed")
+ player.stop()
+ playlist.clear()
+ }
+ break
}
}
@@ -65,6 +74,9 @@ WebSocket {
switch (status) {
case WebSocket.Open:
console.debug("onStatusChanged: Open")
+ sendSocketMessage("subscribe", { value: "media_added" })
+ sendSocketMessage("subscribe", { value: "media_removed" })
+ root.populateMediaPlaylist()
break
case WebSocket.Error:
root.statusString = "WebSocket error: " + root.errorString
@@ -79,4 +91,8 @@ WebSocket {
verbs.push(verb)
sendTextMessage(JSON.stringify(requestJson))
}
+
+ function populateMediaPlaylist() {
+ sendSocketMessage("media_result", 'None')
+ }
}