From 4675d8ebcb9e5f14c2314eefa3eb2fff1ba204b5 Mon Sep 17 00:00:00 2001 From: jcass Date: Fri, 6 Jan 2017 16:54:51 +0200 Subject: [PATCH] Show more appropriate icons for files, tracks, and directories when browsing local folder structure. --- README.rst | 1 + .../static/js/functionsvars.js | 40 ++++++++++++++++++- .../static/js/process_ws.js | 2 +- mopidy_musicbox_webclient/static/mb.appcache | 2 +- 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index a329e75c..81ffcf34 100644 --- a/README.rst +++ b/README.rst @@ -112,6 +112,7 @@ v2.4.0 (UNRELEASED) (Fixes: `#213 `_). - Now shows correct hostname information in loader popup. (Fixes: `#209 `_). - Now shows server name/IP address and port number at the bottom of the navigation pane. (Fixes: `#67 `_). +- Use correct icons for folders, audio, and other files when browsing local files. v2.3.0 (2016-05-15) ------------------- diff --git a/mopidy_musicbox_webclient/static/js/functionsvars.js b/mopidy_musicbox_webclient/static/js/functionsvars.js index 3803bbd9..2ad23b72 100644 --- a/mopidy_musicbox_webclient/static/js/functionsvars.js +++ b/mopidy_musicbox_webclient/static/js/functionsvars.js @@ -77,7 +77,7 @@ var uriClassList = [ ['spotify', 'fa-spotify'], ['spotifytunigo', 'fa-spotify'], ['local', 'fa-file-sound-o'], - ['file', 'fa-folder-o'], + ['file', 'fa-file-o'], ['m3u', 'fa-file-sound-o'], ['podcast', 'fa-rss-square'], ['podcast+file', 'fa-rss-square'], @@ -103,7 +103,7 @@ var uriClassList = [ var uriHumanList = [ ['spotify', 'Spotify'], ['spotifytunigo', 'Spotify browse'], - ['local', 'Local files'], + ['local', 'Local media'], ['m3u', 'Local playlists'], ['podcast', 'Podcasts'], ['podcast+itunes', 'iTunes Store: Podcasts'], @@ -131,6 +131,34 @@ var searchBlacklist = [ 'yt' ] +// List of known audio file extensions +// TODO: consider querying GStreamer for supported audio formats - see:https://discuss.mopidy.com/t/supported-codecs-file-formats/473 +var audioExt = [ + 'aa', 'aax', // Audible.com + 'aac', // Advanced Audio Coding format + 'aiff', // Apple + 'au', // Sun Microsystems + 'flac', // Free Lossless Audio Codec + 'gsm', + 'iklax', + 'ivs', + 'm4a', + 'm4b', + 'm4p', + 'mp3', + 'mpc', // Musepack + 'ogg', 'oga', 'mogg', // Ogg-Vorbis + 'opus', // Internet Engineering Task Force (IETF) + 'ra', 'rm', // RealAudio + 'raw', + 'tta', // True Audio + 'vox', + 'wav', + 'wma', // Microsoft + 'wv', + 'webm' // HTML5 video +] + function scrollToTop () { var divtop = 0 $('body,html').animate({ @@ -493,6 +521,11 @@ function getScheme (uri) { return uri.split(':')[0].toLowerCase() } +function isAudioFile (uri) { + var ext = uri.split('.').pop().toLowerCase() + return $.inArray(ext, audioExt) !== -1 +} + function isStreamUri (uri) { var a = validUri(uri) var b = radioExtensionsList.indexOf(getScheme(uri)) >= 0 @@ -501,6 +534,9 @@ function isStreamUri (uri) { function getMediaClass (uri) { var scheme = getScheme(uri) + if (scheme === 'file' && isAudioFile(uri)) { + return 'fa fa-file-sound-o' + } for (var i = 0; i < uriClassList.length; i++) { if (scheme === uriClassList[i][0]) { return 'fa ' + uriClassList[i][1] diff --git a/mopidy_musicbox_webclient/static/js/process_ws.js b/mopidy_musicbox_webclient/static/js/process_ws.js index a6bfe406..504088db 100644 --- a/mopidy_musicbox_webclient/static/js/process_ws.js +++ b/mopidy_musicbox_webclient/static/js/process_ws.js @@ -106,7 +106,7 @@ function processBrowseDir (resultArr) { index++ } else { var iconClass = '' - if (browseStack.length > 0) { + if (browseStack.length > 0 && resultArr[i].type === 'directory') { iconClass = 'fa fa-folder-o' } else { iconClass = getMediaClass(resultArr[i].uri) diff --git a/mopidy_musicbox_webclient/static/mb.appcache b/mopidy_musicbox_webclient/static/mb.appcache index e0a2b3f0..a6202a42 100644 --- a/mopidy_musicbox_webclient/static/mb.appcache +++ b/mopidy_musicbox_webclient/static/mb.appcache @@ -1,6 +1,6 @@ CACHE MANIFEST -# 2016-12-11:v1 +# 2017-01-06:v1 NETWORK: *