update progress events

This commit is contained in:
Luke Pulverenti 2016-03-07 01:15:24 -05:00
parent eea43db600
commit b9dee7986c
2 changed files with 12 additions and 11 deletions

View File

@ -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)
});

View File

@ -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);
}