From d8c4154947a149db1802a309c116b94845df0b0a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 21 Aug 2016 02:59:36 -0400 Subject: [PATCH] use unified theme media player --- .../emby-input/emby-input.css | 1 - .../emby-input/emby-input.js | 1 + .../emby-webcomponents/require/requirecss.js | 2 +- .../scroller/smoothscroller.js | 28 +++++-- dashboard-ui/metadatasubtitles.html | 80 +++++++++++-------- dashboard-ui/mysync.html | 1 - dashboard-ui/scripts/itemdetailpage.js | 9 --- dashboard-ui/scripts/metadatasubtitles.js | 4 +- dashboard-ui/scripts/mysync.js | 11 +-- dashboard-ui/scripts/site.js | 22 ++++- dashboard-ui/scripts/thememediaplayer.js | 76 ------------------ dashboard-ui/wizarduser.html | 2 +- 12 files changed, 93 insertions(+), 144 deletions(-) delete mode 100644 dashboard-ui/scripts/thememediaplayer.js diff --git a/dashboard-ui/bower_components/emby-webcomponents/emby-input/emby-input.css b/dashboard-ui/bower_components/emby-webcomponents/emby-input/emby-input.css index 7eae6f2bf3..1d8ce5edfc 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/emby-input/emby-input.css +++ b/dashboard-ui/bower_components/emby-webcomponents/emby-input/emby-input.css @@ -17,7 +17,6 @@ font-weight: inherit; color: inherit; padding: .35em 0 .3em 0; - cursor: pointer; outline: none !important; width: 100%; background-color: transparent; diff --git a/dashboard-ui/bower_components/emby-webcomponents/emby-input/emby-input.js b/dashboard-ui/bower_components/emby-webcomponents/emby-input/emby-input.js index 585bf1d0f1..ba9d51ed5a 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/emby-input/emby-input.js +++ b/dashboard-ui/bower_components/emby-webcomponents/emby-input/emby-input.js @@ -46,6 +46,7 @@ var label = this.ownerDocument.createElement('label'); label.innerHTML = this.getAttribute('label') || ''; label.classList.add('inputLabel'); + label.classList.add('inputLabelUnfocused'); var instanceSupportsFloat = supportsFloatingLabel && this.type != 'date'; diff --git a/dashboard-ui/bower_components/emby-webcomponents/require/requirecss.js b/dashboard-ui/bower_components/emby-webcomponents/require/requirecss.js index 83a82972db..4f9063f8f3 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/require/requirecss.js +++ b/dashboard-ui/bower_components/emby-webcomponents/require/requirecss.js @@ -35,7 +35,7 @@ define(function () { var url = cssId + '.css'; - if (url.indexOf('http') != 0 && url.indexOf('file:') != 0) { + if (url.indexOf('://') == -1) { url = config.baseUrl + url; } diff --git a/dashboard-ui/bower_components/emby-webcomponents/scroller/smoothscroller.js b/dashboard-ui/bower_components/emby-webcomponents/scroller/smoothscroller.js index 6f66bbe0fc..d72e4c4156 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/scroller/smoothscroller.js +++ b/dashboard-ui/bower_components/emby-webcomponents/scroller/smoothscroller.js @@ -475,7 +475,7 @@ define(['browser', 'layoutManager', 'dom', 'scrollStyles'], function (browser, l }; }; - self.getCenterPosition = function(item) { + self.getCenterPosition = function (item) { var pos = self.getPos(item); return within(pos.center, pos.start, pos.end); @@ -664,11 +664,15 @@ define(['browser', 'layoutManager', 'dom', 'scrollStyles'], function (browser, l // Bind dragging events if (isTouch) { dragTouchEvents.forEach(function (eventName) { - document.addEventListener(eventName, dragHandler); + dom.addEventListener(document, eventName, dragHandler, { + passive: true + }); }); } else { dragMouseEvents.forEach(function (eventName) { - document.addEventListener(eventName, dragHandler); + dom.addEventListener(document, eventName, dragHandler, { + passive: true + }); }); } @@ -753,11 +757,15 @@ define(['browser', 'layoutManager', 'dom', 'scrollStyles'], function (browser, l if (dragging.touch) { dragTouchEvents.forEach(function (eventName) { - document.removeEventListener(eventName, dragHandler); + dom.removeEventListener(document, eventName, dragHandler, { + passive: true + }); }); } else { dragMouseEvents.forEach(function (eventName) { - document.removeEventListener(eventName, dragHandler); + dom.removeEventListener(document, eventName, dragHandler, { + passive: true + }); }); } @@ -853,7 +861,10 @@ define(['browser', 'layoutManager', 'dom', 'scrollStyles'], function (browser, l */ self.destroy = function () { - window.removeEventListener('resize', onResize, true); + dom.removeEventListener(window, 'resize', onResize, { + passive: true, + capture: true + }); // Reset native FRAME element scroll dom.removeEventListener(frameElement, 'scroll', resetScroll, { @@ -934,7 +945,10 @@ define(['browser', 'layoutManager', 'dom', 'scrollStyles'], function (browser, l dragSourceElement.addEventListener('mousedown', dragInitSlidee); if (!o.scrollWidth) { - window.addEventListener('resize', onResize, true); + dom.addEventListener(window, 'resize', onResize, { + passive: true, + capture: true + }); } if (!o.horizontal) { diff --git a/dashboard-ui/metadatasubtitles.html b/dashboard-ui/metadatasubtitles.html index de7b08cfc7..35887f0fcb 100644 --- a/dashboard-ui/metadatasubtitles.html +++ b/dashboard-ui/metadatasubtitles.html @@ -1,4 +1,4 @@ -
+
@@ -6,48 +6,64 @@
+
+
-
${HeaderDownloadSubtitlesFor}
-
- ${OptionMovies} - ${OptionEpisodes} +

${HeaderDownloadSubtitlesFor}

+
+ +

-
${LabelDownloadLanguages}
-
+

${LabelDownloadLanguages}

+


-
    -
  • - ${OptionRequirePerfectSubtitleMatch} -
  • -
  • - ${LabelSkipIfAudioTrackPresent} -
    ${LabelSkipIfAudioTrackPresentHelp}
    -
  • -
  • - ${LabelSkipIfGraphicalSubsPresent} -
    ${LabelSkipIfGraphicalSubsPresentHelp}
    -
  • -
  • - - -
  • -
  • - -
  • -
-
    -
  • - -
  • -
+ +
+ +
${LabelSkipIfAudioTrackPresentHelp}
+
+
+ +
${LabelSkipIfGraphicalSubsPresentHelp}
+
+
+
+ + +
+ +
+ +
+ +
+ +
diff --git a/dashboard-ui/mysync.html b/dashboard-ui/mysync.html index 16cd88f635..a64f2e9c5d 100644 --- a/dashboard-ui/mysync.html +++ b/dashboard-ui/mysync.html @@ -30,7 +30,6 @@

-
diff --git a/dashboard-ui/scripts/itemdetailpage.js b/dashboard-ui/scripts/itemdetailpage.js index d25c1381c6..ac17d13854 100644 --- a/dashboard-ui/scripts/itemdetailpage.js +++ b/dashboard-ui/scripts/itemdetailpage.js @@ -1531,16 +1531,7 @@ renderThemeSongs(page, themeSongs); renderThemeVideos(page, themeVideos); - - page.dispatchEvent(new CustomEvent("thememediadownload", { - detail: { - themeMediaResult: result - }, - bubbles: true - })); - }); - } function renderThemeSongs(page, items) { diff --git a/dashboard-ui/scripts/metadatasubtitles.js b/dashboard-ui/scripts/metadatasubtitles.js index a95deb8916..7e78fbcb7e 100644 --- a/dashboard-ui/scripts/metadatasubtitles.js +++ b/dashboard-ui/scripts/metadatasubtitles.js @@ -1,4 +1,4 @@ -define(['jQuery'], function ($) { +define(['jQuery', 'fnchecked'], function ($) { function loadPage(page, config, languages) { @@ -25,7 +25,7 @@ var culture = languages[i]; - html += '' + culture.DisplayName + ''; + html += ''; } $('.downloadLanguages', page).html(html); diff --git a/dashboard-ui/scripts/mysync.js b/dashboard-ui/scripts/mysync.js index f4c96efcec..211138d80d 100644 --- a/dashboard-ui/scripts/mysync.js +++ b/dashboard-ui/scripts/mysync.js @@ -1,4 +1,4 @@ -define(['loading', 'apphost', 'globalize', 'syncJobList', 'events', 'localsync', 'emby-button', 'paper-icon-button-light'], function (loading, appHost, globalize, syncJobList, events, localSync) { +define(['apphost', 'globalize', 'syncJobList', 'events', 'localsync', 'emby-button', 'paper-icon-button-light'], function (appHost, globalize, syncJobList, events, localSync) { function initSupporterInfo(view, params) { @@ -40,13 +40,6 @@ var status = localSync.getSyncStatus(); - page.querySelector('.labelSyncStatus').innerHTML = Globalize.translate('LabelLocalSyncStatusValue', status); - if (status == 'Active') { - loading.show(); - } else { - loading.hide(); - } - if (status == "Active") { page.querySelector('.btnSyncNow').classList.add('hide'); } @@ -103,8 +96,6 @@ view.addEventListener('viewbeforehide', function () { - loading.hide(); - if (interval) { clearInterval(interval); interval = null; diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 98f78b8830..32365722c5 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -179,7 +179,7 @@ var Dashboard = { } if (url.indexOf('/') != 0) { - if (url.indexOf('http') != 0 && url.indexOf('file:') != 0) { + if (url.indexOf('://') == -1) { url = '/' + url; } } @@ -1528,10 +1528,21 @@ var AppInfo = {}; // mock this for now. not used in this app define("playbackManager", [], function () { return { + isPlaying: function () { + return MediaPlayer.currentItem != null; + }, isPlayingVideo: function () { - return false; + return MediaPlayer.currentItem != null; }, play: function (options) { + + if (options.fullscreen === false) { + // theme backdrops - not supported + if (!options.items || options.items[0].MediaType == 'Video') { + return; + } + } + MediaController.play(options); }, currentPlaylistIndex: function (options) { @@ -1554,6 +1565,9 @@ var AppInfo = {}; }, pause: function () { return MediaController.pause(); + }, + stop: function () { + return MediaController.stop(); } }; }); @@ -1645,7 +1659,7 @@ var AppInfo = {}; apiClient.getItem(apiClient.getCurrentUserId(), item).then(showItem); }); } else { - Dashboard.navigate(LibraryBrowser.getHref(item)); + Emby.Page.show('/' + LibraryBrowser.getHref(item), { item: item }); } } @@ -2726,7 +2740,7 @@ var AppInfo = {}; var postInitDependencies = []; - postInitDependencies.push('scripts/thememediaplayer'); + postInitDependencies.push('bower_components/emby-webcomponents/thememediaplayer'); postInitDependencies.push('scripts/remotecontrol'); postInitDependencies.push('css!css/chromecast.css'); postInitDependencies.push('scripts/autobackdrops'); diff --git a/dashboard-ui/scripts/thememediaplayer.js b/dashboard-ui/scripts/thememediaplayer.js deleted file mode 100644 index 5d6eabf682..0000000000 --- a/dashboard-ui/scripts/thememediaplayer.js +++ /dev/null @@ -1,76 +0,0 @@ -define(['appStorage'], function (appStorage) { - - var currentOwnerId; - var currentThemeIds = []; - - function playThemeSongs(items, ownerId) { - - var player = getPlayer(); - - if (items.length && player.isDefaultPlayer && player.canAutoPlayAudio()) { - - // Stop if a theme song from another ownerId - // Leave it alone if anything else (e.g user playing a movie) - if (!currentOwnerId && player.isPlaying()) { - return; - } - - currentThemeIds = items.map(function (i) { - return i.Id; - }); - - currentOwnerId = ownerId; - - player.play({ - items: items - }); - - } else { - currentOwnerId = null; - } - } - - function onPlayItem(item) { - - // User played something manually - if (currentThemeIds.indexOf(item.Id) == -1) { - - currentOwnerId = null; - - } - } - - function enabled() { - - var userId = Dashboard.getCurrentUserId(); - - var val = appStorage.getItem('enableThemeSongs-' + userId); - - var localAutoPlayers = MediaController.getPlayers().filter(function (p) { - - return p.isLocalPlayer && p.canAutoPlayAudio(); - }); - - // For bandwidth - return val == '1' || (val != '0' && localAutoPlayers.length); - } - - function getPlayer() { - return MediaController.getCurrentPlayer(); - } - - document.addEventListener('thememediadownload', function (e) { - - if (!enabled()) { - return; - } - - var themeMediaResult = e.detail.themeMediaResult; - var ownerId = themeMediaResult.ThemeSongsResult.OwnerId; - - if (ownerId != currentOwnerId) { - playThemeSongs(themeMediaResult.ThemeSongsResult.Items, ownerId); - } - }); - -}); \ No newline at end of file diff --git a/dashboard-ui/wizarduser.html b/dashboard-ui/wizarduser.html index 962d0deb71..8a0c1b8d2b 100644 --- a/dashboard-ui/wizarduser.html +++ b/dashboard-ui/wizarduser.html @@ -1,4 +1,4 @@ -
+