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/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 `_. 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 26ec9bc2..0d3835fb 100644 --- a/mopidy_musicbox_webclient/static/js/gui.js +++ b/mopidy_musicbox_webclient/static/js/gui.js @@ -16,9 +16,47 @@ function resetSong () { data.track.artists = '' data.track.length = 0 data.track.uri = '' + data.stream = '' setSongInfo(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 + } + $('#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 + showSongInfo(songdata) +} + function resizeMb () { if ($(window).width() < 880) { $('#panel').panel('close') @@ -26,8 +64,7 @@ function resizeMb () { $('#panel').panel('open') } - $('#infoname').html(songdata.track.name) - $('#infoartist').html(artiststext) + showSongInfo(songdata) if ($(window).width() > 960) { $('#playlisttracksdiv').show() @@ -35,14 +72,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 } @@ -52,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) { @@ -63,13 +90,10 @@ function setSongInfo (data) { } } } - songdata = data - setSongTitle(data.track, false) - 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); @@ -80,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 @@ -106,8 +132,6 @@ function setSongInfo (data) { '') } - $('#modalartist').html(arttmp) - $('#trackslider').attr('min', 0) $('#trackslider').attr('max', songlength) syncedProgressTimer.reset().set(0, songlength) @@ -282,8 +306,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/library.js b/mopidy_musicbox_webclient/static/js/library.js index 79154956..2cd73d3d 100644 --- a/mopidy_musicbox_webclient/static/js/library.js +++ b/mopidy_musicbox_webclient/static/js/library.js @@ -275,7 +275,12 @@ $('#controlsmodal').popup('close') $(ARTIST_TABLE).empty() + if (!nwuri.length || nwuri === 'undefined') { + return false + } + // TODO cache + $('#h_artistname').html('') showLoading(true) mopidy.library.lookup({'uris': [nwuri]}).then(function (resultDict) { @@ -293,6 +298,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) { 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) } /** ****************************************************** 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