From f3ddc376291262a6b305cc2b0a52792abdc7c85c Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Thu, 25 May 2017 16:52:13 -0700 Subject: 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 --- app/api/LightMediaScanner.qml | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'app/api') 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') + } } -- cgit 1.2.3-korg