diff --git a/dashboard-ui/scripts/externalplayer.js b/dashboard-ui/scripts/externalplayer.js
index 91bf8eb96e..e3dad85ae1 100644
--- a/dashboard-ui/scripts/externalplayer.js
+++ b/dashboard-ui/scripts/externalplayer.js
@@ -1,4 +1,4 @@
-(function (window) {
+define(['paper-slider', 'paper-button'], function () {
function getDeviceProfile(serverAddress, deviceId, item, startPositionTicks, maxBitrate, mediaSourceId, audioStreamIndex, subtitleStreamIndex) {
@@ -104,20 +104,19 @@
function getVideoStreamInfo(item) {
- var deferred = $.Deferred();
-
var deviceProfile = getDeviceProfile();
var startPosition = 0;
- MediaPlayer.tryStartPlayback(deviceProfile, item, startPosition, function (mediaSource) {
+ return new Promise(function (resolve, reject) {
- playInternalPostMediaSourceSelection(item, mediaSource, startPosition, deferred);
+ MediaPlayer.tryStartPlayback(deviceProfile, item, startPosition, function (mediaSource) {
+
+ playInternalPostMediaSourceSelection(item, mediaSource, startPosition).then(resolve);
+ });
});
-
- return deferred.promise();
}
- function playInternalPostMediaSourceSelection(item, mediaSource, startPosition, deferred) {
+ function playInternalPostMediaSourceSelection(item, mediaSource, startPosition) {
Dashboard.hideLoadingMsg();
@@ -130,7 +129,7 @@
}
};
- MediaPlayer.createStreamInfo('Video', item, mediaSource, startPosition).then(function (streamInfo) {
+ return MediaPlayer.createStreamInfo('Video', item, mediaSource, startPosition).then(function (streamInfo) {
var currentSrc = streamInfo.url;
@@ -152,7 +151,7 @@
basePlayerState.PlayState.CanSeek = false;
basePlayerState.NowPlayingItem = MediaPlayer.getNowPlayingItemForReporting(item, mediaSource);
- deferred.resolveWith(null, [streamInfo]);
+ return streamInfo;
});
}
@@ -160,15 +159,13 @@
var state = basePlayerState;
- state.PlayState.PositionTicks = positionTicks;
+ state.PlayState.PositionTicks = Math.round(positionTicks);
return state;
}
function onPlaybackStart() {
- closePlayMenu();
-
var state = getPlayerState();
var info = {
@@ -186,12 +183,7 @@
}, 10000);
- // Need a timeout because we can't show a popup at the same time as the previous one is closing
- // Bumping it up to 1000 because the post play menu is hiding for some reason on android
- setTimeout(function () {
-
- showPostPlayMenu(currentItem);
- }, 1000);
+ showPostPlayMenu(currentItem);
}
function onPlaybackProgress(positionTicks) {
@@ -213,9 +205,9 @@
var state = getPlayerState(positionTicks);
var stopInfo = {
- itemId: state.NowPlayingItem.Id,
- mediaSourceId: state.PlayState.MediaSourceId,
- positionTicks: state.PlayState.PositionTicks
+ ItemId: state.NowPlayingItem.Id,
+ MediaSourceId: state.PlayState.MediaSourceId,
+ PositionTicks: state.PlayState.PositionTicks
};
if (state.PlayState.LiveStreamId) {
@@ -226,12 +218,15 @@
stopInfo.PlaySessionId = state.PlayState.PlaySessionId;
}
- ApiClient.reportPlaybackStopped(stopInfo);
-
if (progressInterval) {
clearInterval(progressInterval);
progressInterval = null;
}
+
+ // Make sure this is after progress reports have stopped
+ setTimeout(function () {
+ ApiClient.reportPlaybackStopped(stopInfo);
+ }, 1000);
}
function showPostPlayMenu(item) {
@@ -245,7 +240,7 @@
html += '
' + Globalize.translate('HeaderExternalPlayerPlayback') + ' ';
html += '';
- html += '';
+ html += '
';
var autoMarkWatched = item.RunTimeTicks;
@@ -253,29 +248,26 @@
autoMarkWatched = false;
- html += '
';
- html += '' + Globalize.translate('LabelMarkAs') + ' ';
- html += '' + Globalize.translate('OptionUnwatched') + ' ';
- html += ' ';
- html += '' + Globalize.translate('OptionWatched') + ' ';
- html += ' ';
- html += '' + Globalize.translate('OptionInProgress') + ' ';
- html += ' ';
- html += ' ';
+ html += '
' + Globalize.translate('LabelMarkAs') + ' ';
+ html += '
';
+ html += '' + Globalize.translate('OptionWatched') + ' ';
+ html += '' + Globalize.translate('OptionUnwatched') + ' ';
+ html += '' + Globalize.translate('OptionInProgress') + ' ';
+ html += ' ';
html += '
';
+ html += '
';
html += '
' + Globalize.translate('LabelResumePoint') + '
';
- html += '
';
- html += ' ';
- html += '
';
+ html += '
';
html += '
0:00:00
';
+ html += '
';
html += '
';
}
- html += '
' + Globalize.translate('ButtonImDone') + ' ';
+ html += '
' + Globalize.translate('ButtonImDone') + ' ';
html += '
';
@@ -287,42 +279,41 @@
$(this).off("popupafterclose").remove();
- });
+ })[0];
- $('.radioPlaystate', elem).on('change', function () {
+ $('#selectMarkAs', elem).on('change', function () {
- if ($('#radioMarkInProgress', elem).checked()) {
+ if (this.value == '2') {
- $('.playstateSlider', elem).slider('enable');
+ elem.querySelector('.fldResumePoint').classList.remove('hide');
} else {
- $('.playstateSlider', elem).slider('disable');
+ elem.querySelector('.fldResumePoint').classList.add('hide');
}
}).trigger('change');
$('.btnDone', elem).on('click', function () {
- $('.externalPlayerPostPlayFlyout').popup("close").remove();
-
var position = 0;
-
- if ($('#radioMarkInProgress', elem).checked()) {
+ var playstateOption = $('#selectMarkAs', elem).val();
+ if (playstateOption == '2') {
var pct = $(".playstateSlider", elem).val();
var ticks = item.RunTimeTicks * (Number(pct) * .01);
position = ticks;
}
- else if (autoMarkWatched || $('#radioMarkWatched', elem).checked()) {
+ else if (autoMarkWatched || playstateOption == '0') {
position = currentMediaSource.RunTimeTicks;
}
- else if ($('#radioMarkUnwatched', elem).checked()) {
+ else if (playstateOption == '1') {
position = 0;
}
onPlaybackStopped(position);
+ $('.externalPlayerPostPlayFlyout').popup("close").remove();
});
$(".playstateSlider", elem).on("change", function (e) {
@@ -341,44 +332,22 @@
});
}
- function closePlayMenu() {
- $('.externalPlayerFlyout').popup("close").remove();
- }
-
function showMenuForItem(item, players) {
- require(['jqmpopup', 'jqmlistview'], function () {
- closePlayMenu();
+ require(['actionsheet'], function (actionsheet) {
- var html = '
';
+ actionsheet.show({
+ items: players,
+ callback: function (id) {
+ var player = players.filter(function (p) {
+ return p.id == id;
+ })[0];
- html += '
';
- html += '' + Globalize.translate('HeaderSelectExternalPlayer') + ' ';
- html += ' ';
-
- html += '
';
-
- html += players.map(function (p) {
-
- return '
' + p.name + ' ';
-
- }).join('');
-
- html += '
';
-
- html += '
';
-
- $(document.body).append(html);
-
- var elem = $('.externalPlayerFlyout').popup({}).trigger('create').popup("open").on("popupafterclose", function () {
-
- $(this).off("popupafterclose").remove();
-
- });
-
- $('.btnExternalPlayer', elem).on('click', function () {
-
- ExternalPlayer.onPlaybackStart();
+ if (player) {
+ window.open(player.url, '_blank');
+ onPlaybackStart();
+ }
+ }
});
});
}
@@ -401,7 +370,10 @@
function getExternalPlayers(url, mimeType) {
var players = [
- { name: 'Vlc', url: 'vlc://' + url, id: 'vlc' }
+ {
+ name: 'Vlc', url: 'vlc://' + url, id: 'vlc',
+ ironIcon: 'airplay'
+ }
];
return Promise.resolve(players);
@@ -422,4 +394,4 @@
showPlayerSelectionMenu: showPlayerSelectionMenu
};
-})(window);
\ No newline at end of file
+});
\ No newline at end of file
diff --git a/dashboard-ui/scripts/librarymenu.js b/dashboard-ui/scripts/librarymenu.js
index 922858b7d5..714508965b 100644
--- a/dashboard-ui/scripts/librarymenu.js
+++ b/dashboard-ui/scripts/librarymenu.js
@@ -33,9 +33,7 @@
html += '';
- if (!showUserAtTop()) {
- html += '';
- }
+ html += '';
if (!browserInfo.mobile && !Dashboard.isConnectMode()) {
html += '';
@@ -288,44 +286,14 @@
var html = '';
- var userAtTop = showUserAtTop();
-
var homeHref = window.ApiClient ? 'index.html' : 'selectserver.html?showuser=1';
- var hasUserImage = user.imageUrl;
+ html += '
';
- if (userAtTop) {
-
- html += '
';
-
- var imgWidth = 40;
-
- if (hasUserImage) {
- var url = user.imageUrl;
- if (user.supportsImageParams) {
- url += "&width=" + (imgWidth * Math.max(devicePixelRatio || 1, 2));
- html += '
';
- }
- } else {
- html += '
';
- }
-
- html += '
';
- html += user.name;
- html += '
';
-
- html += '
';
-
- html += '';
-
- } else {
- html += '
';
-
- html += '';
- }
+ html += '';
html += '';
@@ -386,7 +354,7 @@
html += '';
- if (user.localUser && showUserAtTop()) {
+ if (user.localUser && (AppInfo.isNativeApp && browserInfo.android)) {
html += '';
}
@@ -396,7 +364,7 @@
html += '';
}
- if (showUserAtTop()) {
+ if (user.localUser) {
html += '';
}
@@ -556,10 +524,6 @@
}
}
- function showUserAtTop() {
- return false;
- }
-
var requiresLibraryMenuRefresh = false;
function onManageServerClicked() {