Skip to content

Commit

Permalink
Merge pull request #219 from jcass77/enhance/file_icons
Browse files Browse the repository at this point in the history
More appropriate icons when browsing local folders.
  • Loading branch information
kingosticks authored Jan 6, 2017
2 parents c264bc5 + 4675d8e commit f3a45d0
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ v2.4.0 (UNRELEASED)
(Fixes: `#213 <https://github.com/pimusicbox/mopidy-musicbox-webclient/issues/213>`_).
- Now shows correct hostname information in loader popup. (Fixes: `#209 <https://github.com/pimusicbox/mopidy-musicbox-webclient/issues/209>`_).
- Now shows server name/IP address and port number at the bottom of the navigation pane. (Fixes: `#67 <https://github.com/pimusicbox/mopidy-musicbox-webclient/issues/67>`_).
- Use correct icons for folders, audio, and other files when browsing local files.

v2.3.0 (2016-05-15)
-------------------
Expand Down
40 changes: 38 additions & 2 deletions mopidy_musicbox_webclient/static/js/functionsvars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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'],
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion mopidy_musicbox_webclient/static/js/process_ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion mopidy_musicbox_webclient/static/mb.appcache
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CACHE MANIFEST

# 2016-12-11:v1
# 2017-01-06:v1

NETWORK:
*
Expand Down

0 comments on commit f3a45d0

Please sign in to comment.