From ab4da718e43c7aab9ac18e066d6cffba54e5d496 Mon Sep 17 00:00:00 2001 From: Nick Steel Date: Tue, 3 Mar 2020 19:08:35 +0000 Subject: [PATCH 1/6] Install using sudo --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 5f937083..6cc74f0e 100644 --- a/README.rst +++ b/README.rst @@ -52,7 +52,7 @@ Installation Install by running:: - python3 -m pip install Mopidy-MusicBox-Webclient + sudo python3 -m pip install Mopidy-MusicBox-Webclient Or, if available, install the Debian/Ubuntu package from `apt.mopidy.com `_. From 14cffe555cf4c4edebd3e8fd14c7651bdac98e44 Mon Sep 17 00:00:00 2001 From: Nick Steel Date: Tue, 12 Feb 2019 17:47:51 +0000 Subject: [PATCH 2/6] Fetch and show stream title is available (Fixes #259). --- mopidy_musicbox_webclient/static/js/gui.js | 34 +++++++++++-------- .../static/js/process_ws.js | 5 ++- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/mopidy_musicbox_webclient/static/js/gui.js b/mopidy_musicbox_webclient/static/js/gui.js index 26ec9bc2..a2ac39d8 100644 --- a/mopidy_musicbox_webclient/static/js/gui.js +++ b/mopidy_musicbox_webclient/static/js/gui.js @@ -16,9 +16,25 @@ function resetSong () { data.track.artists = '' data.track.length = 0 data.track.uri = '' + data.stream = '' setSongInfo(data) } +function setSongTitle (data) { + var name = data.track.name + if (data.stream) { + name = data.stream + ' || ' + data.track.name + console.log('Setting name %s', name) + } + $('#modalname').html('' + name + '') + $('#infoname').html(name) +} + +function setStreamTitle (title) { + songdata.stream = title + setSongTitle(songdata) +} + function resizeMb () { if ($(window).width() < 880) { $('#panel').panel('close') @@ -26,7 +42,7 @@ function resizeMb () { $('#panel').panel('open') } - $('#infoname').html(songdata.track.name) + setSongTitle(songdata) $('#infoartist').html(artiststext) if ($(window).width() > 960) { @@ -35,14 +51,6 @@ function resizeMb () { } } -function setSongTitle (track, refresh_ui) { - songdata.track.name = track.name - $('#modalname').html('' + track.name + '') - if (refresh_ui) { - resizeMb() - } -} - function setSongInfo (data) { if (!data) { return } if (data.tlid === songdata.tlid) { return } @@ -63,10 +71,7 @@ function setSongInfo (data) { } } } - songdata = data - - setSongTitle(data.track, false) songlength = Infinity if (!data.track.length || data.track.length === 0) { @@ -282,8 +287,9 @@ function initSocketevents () { }) mopidy.on('event:streamTitleChanged', function (data) { - // Update all track info. - mopidy.playback.getCurrentTlTrack().then(processCurrenttrack, console.error) + // The stream title is separate from the current track. + setStreamTitle(data.title) + controls.setPlayState(true) }) } diff --git a/mopidy_musicbox_webclient/static/js/process_ws.js b/mopidy_musicbox_webclient/static/js/process_ws.js index 00d8afe5..87f8ace2 100644 --- a/mopidy_musicbox_webclient/static/js/process_ws.js +++ b/mopidy_musicbox_webclient/static/js/process_ws.js @@ -6,10 +6,13 @@ */ /** ****************************************************** - * process results of a (new) currently playing track + * process results of a (new) currently playing track and any stream title *********************************************************/ function processCurrenttrack (data) { setSongInfo(data) + mopidy.playback.getStreamTitle().then(function (title) { + setStreamTitle(title) + }, console.error) } /** ****************************************************** From c32b535e31cc68ad1b52ec78a5ceb07b5d9374f2 Mon Sep 17 00:00:00 2001 From: Nick Steel Date: Tue, 19 Feb 2019 14:42:44 +0000 Subject: [PATCH 3/6] Fixed trying to load artist/album info forever when we don't have a uri. --- mopidy_musicbox_webclient/static/js/library.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mopidy_musicbox_webclient/static/js/library.js b/mopidy_musicbox_webclient/static/js/library.js index 79154956..35b20f6a 100644 --- a/mopidy_musicbox_webclient/static/js/library.js +++ b/mopidy_musicbox_webclient/static/js/library.js @@ -275,7 +275,11 @@ $('#controlsmodal').popup('close') $(ARTIST_TABLE).empty() - // TODO cache + if (!nwuri.length || nwuri == 'undefined') { + return false + } + + // TODO cache $('#h_artistname').html('') showLoading(true) mopidy.library.lookup({'uris': [nwuri]}).then(function (resultDict) { @@ -293,6 +297,11 @@ $('#popupTracks').popup('close') $('#controlsmodal').popup('close') $(ALBUM_TABLE).empty() + + if (!uri.length || uri == 'undefined') { + return false + } + // fill from cache var pl = getTracksFromUri(uri, true) if (pl.length > 0) { From e60281adc7674c6f1964def6223524375f95119b Mon Sep 17 00:00:00 2001 From: Nick Steel Date: Tue, 19 Feb 2019 14:44:21 +0000 Subject: [PATCH 4/6] Better artist/album/name handling when info is missing. Clickable now-playing links have visual highlight. Show track name for streams in place of missing album/artist info. --- .../static/css/webclient.css | 5 +- mopidy_musicbox_webclient/static/index.html | 4 +- .../static/js/functionsvars.js | 6 +- mopidy_musicbox_webclient/static/js/gui.js | 61 ++++++++++++------- 4 files changed, 49 insertions(+), 27 deletions(-) diff --git a/mopidy_musicbox_webclient/static/css/webclient.css b/mopidy_musicbox_webclient/static/css/webclient.css index 2cafa99f..50b15570 100644 --- a/mopidy_musicbox_webclient/static/css/webclient.css +++ b/mopidy_musicbox_webclient/static/css/webclient.css @@ -423,8 +423,9 @@ span.hostInfo { /************ * Popups * ************/ -#modalalbum a, #modalartist a, #modalname a { +#modalname a, #modaldetail a { color: #444; + background-color:#F8F8F5; text-decoration: none; } @@ -587,7 +588,7 @@ a { text-overflow: ellipsis; } -#infoartist { +#infodetail { overflow: hidden; font-size: 11px; white-space: nowrap; diff --git a/mopidy_musicbox_webclient/static/index.html b/mopidy_musicbox_webclient/static/index.html index 715c7b0d..b4793425 100644 --- a/mopidy_musicbox_webclient/static/index.html +++ b/mopidy_musicbox_webclient/static/index.html @@ -340,7 +340,7 @@

System

-

-

+

@@ -516,7 +516,7 @@

Streams

Album cover
-
+
diff --git a/mopidy_musicbox_webclient/static/js/functionsvars.js b/mopidy_musicbox_webclient/static/js/functionsvars.js index b53197c8..f1ffe5db 100644 --- a/mopidy_musicbox_webclient/static/js/functionsvars.js +++ b/mopidy_musicbox_webclient/static/js/functionsvars.js @@ -23,8 +23,10 @@ var initgui = true var popupData = {} // TODO: Refactor into one shared cache var songlength = 0 -var artistshtml = '' -var artiststext = '' +var artistsHtml = '' +var artistsText = '' +var albumHtml = '' +var albumText = '' var songname = '' var songdata = {'track': {}, 'tlid': -1} diff --git a/mopidy_musicbox_webclient/static/js/gui.js b/mopidy_musicbox_webclient/static/js/gui.js index a2ac39d8..0d3835fb 100644 --- a/mopidy_musicbox_webclient/static/js/gui.js +++ b/mopidy_musicbox_webclient/static/js/gui.js @@ -20,19 +20,41 @@ function resetSong () { setSongInfo(data) } -function setSongTitle (data) { +/* Name: Use stream title if we have it, else track name. + * Detail: If we don't know artist and it's a stream then show track name instead. + * If we know both artist and album show them, otherwise just show artist if we know it. + */ +function showSongInfo (data) { var name = data.track.name if (data.stream) { - name = data.stream + ' || ' + data.track.name - console.log('Setting name %s', name) + name = data.stream } $('#modalname').html('' + name + '') + if (!artistsHtml && data.stream) { + $('#modaldetail').html(data.track.name) + } else if (artistsHtml.length) { + if (albumHtml.length) { + $('#modaldetail').html(albumHtml + ' - ' + artistsHtml) + } else { + $('#modaldetail').html(artistsHtml) + } + } + $('#infoname').html(name) + if (!artistsText && data.stream) { + $('#infodetail').html(data.track.name) + } else if (artistsText.length) { + if (albumText.length) { + $('#infodetail').html(albumText + ' - ' + artistsText) + } else { + $('#infodetail').html(artistsText) + } + } } function setStreamTitle (title) { songdata.stream = title - setSongTitle(songdata) + showSongInfo(songdata) } function resizeMb () { @@ -42,8 +64,7 @@ function resizeMb () { $('#panel').panel('open') } - setSongTitle(songdata) - $('#infoartist').html(artiststext) + showSongInfo(songdata) if ($(window).width() > 960) { $('#playlisttracksdiv').show() @@ -60,8 +81,6 @@ function setSongInfo (data) { } updatePlayIcons(data.track.uri, data.tlid, controls.getIconForAction()) - artistshtml = '' - artiststext = '' if (validUri(data.track.name)) { for (var key in streamUris) { @@ -72,9 +91,9 @@ function setSongInfo (data) { } } songdata = data - songlength = Infinity if (!data.track.length || data.track.length === 0) { + songlength = Infinity $('#trackslider').next().find('.ui-slider-handle').hide() $('#trackslider').slider('disable') // $('#streamnameinput').val(data.track.name); @@ -85,24 +104,26 @@ function setSongInfo (data) { $('#trackslider').next().find('.ui-slider-handle').show() } - var arttmp = '' - + artistsHtml = '' + artistsText = '' if (data.track.artists) { for (var j = 0; j < data.track.artists.length; j++) { - artistshtml += '' + data.track.artists[j].name + '' - artiststext += data.track.artists[j].name + var artistName = data.track.artists[j].name if (j !== data.track.artists.length - 1) { - artistshtml += ', ' - artiststext += ', ' + artistName += ', ' } + artistsHtml += '' + artistName + '' + artistsText += artistName } - arttmp = artistshtml } + + albumHtml = '' + albumText = '' if (data.track.album && data.track.album.name) { - $('#modalalbum').html('' + data.track.album.name + '') - } else { - $('#modalalbum').html('') + albumHtml = '' + data.track.album.name + '' + albumText = data.track.album.name } + images.setAlbumImage(data.track.uri, '#infocover, #albumCoverImg', mopidy) if (data.track.uri) { // Add 'Show Info' icon to album image @@ -111,8 +132,6 @@ function setSongInfo (data) { '') } - $('#modalartist').html(arttmp) - $('#trackslider').attr('min', 0) $('#trackslider').attr('max', songlength) syncedProgressTimer.reset().set(0, songlength) From 5b786aac3c55dddeb889e54020453ed878000e70 Mon Sep 17 00:00:00 2001 From: Nick Steel Date: Sun, 22 Mar 2020 21:37:32 +0000 Subject: [PATCH 5/6] fix eslint complaints --- mopidy_musicbox_webclient/static/js/library.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mopidy_musicbox_webclient/static/js/library.js b/mopidy_musicbox_webclient/static/js/library.js index 35b20f6a..2cd73d3d 100644 --- a/mopidy_musicbox_webclient/static/js/library.js +++ b/mopidy_musicbox_webclient/static/js/library.js @@ -275,11 +275,12 @@ $('#controlsmodal').popup('close') $(ARTIST_TABLE).empty() - if (!nwuri.length || nwuri == 'undefined') { + if (!nwuri.length || nwuri === 'undefined') { return false } - // TODO cache + // TODO cache + $('#h_artistname').html('') showLoading(true) mopidy.library.lookup({'uris': [nwuri]}).then(function (resultDict) { @@ -298,7 +299,7 @@ $('#controlsmodal').popup('close') $(ALBUM_TABLE).empty() - if (!uri.length || uri == 'undefined') { + if (!uri.length || uri === 'undefined') { return false } From 5810cc77f9f936df0b006fe15fdc2dfacfd6b616 Mon Sep 17 00:00:00 2001 From: Nick Steel Date: Sun, 22 Mar 2020 21:55:54 +0000 Subject: [PATCH 6/6] Prepare release 3.1.0 --- CHANGELOG.rst | 6 ++++++ setup.cfg | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 80db1761..a101b6a8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,6 +3,12 @@ Changelog ********* +v3.1.0 (2020-03-22) +=================== + +- Display stream title when available. (PR: #261) +- Fixed loading artist/album info forever when uri is missing. + v3.0.1 (2019-12-22) =================== diff --git a/setup.cfg b/setup.cfg index 61f72a17..0d3c2b8c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = Mopidy-MusicBox-Webclient -version = 3.0.1 +version = 3.1.0 url = https://github.com/pimusicbox/mopidy-musicbox-webclient author = Wouter van Wijk author_email = woutervanwijk@gmail.com