From b9dee7986cf0b09f0cdf34b59b0d0ecc623123d4 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 7 Mar 2016 01:15:24 -0500 Subject: [PATCH] update progress events --- components/embyactions.js | 4 ++-- components/maincontroller.js | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/components/embyactions.js b/components/embyactions.js index 0b41e37..3449e7c 100644 --- a/components/embyactions.js +++ b/components/embyactions.js @@ -109,7 +109,7 @@ }); }; - factory.reportPlaybackProgress = function ($scope, options, reportToServer) { + factory.reportPlaybackProgress = function ($scope, options, reportToServer, broadcastEventName) { if (!$scope.userId) { throw new Error("null userId"); @@ -122,7 +122,7 @@ //console.log(JSON.stringify(getSenderReportingData($scope, options))); broadcastToMessageBus({ - type: 'playbackprogress', + type: broadcastEventName || 'playbackprogress', data: getSenderReportingData($scope, options) }); diff --git a/components/maincontroller.js b/components/maincontroller.js index afac41d..fab14fc 100644 --- a/components/maincontroller.js +++ b/components/maincontroller.js @@ -189,7 +189,7 @@ // Items will have properties - Id, Name, Type, MediaType, IsFolder - var reportProgress = false; + var reportEventType; if (data.command == 'PlayLast' || data.command == 'PlayNext') { @@ -236,17 +236,18 @@ else if (data.command == 'VolumeUp') { window.mediaElement.volume = Math.min(1, window.mediaElement.volume + .2); - reportProgress = true; + reportEventType = 'volumechange'; } else if (data.command == 'VolumeDown') { // TODO window.mediaElement.volume = Math.max(0, window.mediaElement.volume - .2); - reportProgress = true; + reportEventType = 'volumechange'; } else if (data.command == 'ToggleMute') { // TODO + reportEventType = 'volumechange'; } else if (data.command == 'Identify') { @@ -259,7 +260,7 @@ // Scale 0-100 window.mediaElement.volume = data.options.volume / 100; - reportProgress = true; + reportEventType = 'volumechange'; } else if (data.command == 'Seek') { seek(data.options.position * 10000000); @@ -280,12 +281,12 @@ } else { window.mediaElement.pause(); } - reportProgress = true; + reportEventType = 'playstatechange'; } else if (data.command == 'Pause') { window.mediaElement.pause(); - reportProgress = true; + reportEventType = 'playstatechange'; } else if (data.command == 'SetRepeatMode') { @@ -295,19 +296,19 @@ else if (data.command == 'Unpause') { window.mediaElement.play(); - reportProgress = true; + reportEventType = 'playstatechange'; } else { translateItems(data, data.options, data.options.items, 'play'); } - if (reportProgress) { + if (reportEventType) { var report = function() { embyActions.reportPlaybackProgress($scope, getReportingParams($scope)); }; - report(); + embyActions.reportPlaybackProgress($scope, getReportingParams($scope), true, reportEventType); setTimeout(report, 100); setTimeout(report, 500); }