From d1f8c381b7aabba27d261274548fa5b51e3dcc94 Mon Sep 17 00:00:00 2001 From: Alib Date: Tue, 16 Mar 2010 01:28:39 +0100 Subject: audio stream in progress --- bin/backend.php | 9 +++- bin/textfiles/browseAudio.txt | 21 --------- bin/textfiles/browseFolder-aud.txt | 36 +++++++++++++++ bin/textfiles/getGlobals.txt | 2 +- bin/textfiles/streamAudio.txt | 2 +- css/istreamdev.css | 8 ++-- index.html | 20 +-------- js/istreamdev.js | 89 ++++++++++++++++++++++++++++++-------- 8 files changed, 122 insertions(+), 65 deletions(-) delete mode 100644 bin/textfiles/browseAudio.txt create mode 100644 bin/textfiles/browseFolder-aud.txt diff --git a/bin/backend.php b/bin/backend.php index 54e0058..b2c41b3 100644 --- a/bin/backend.php +++ b/bin/backend.php @@ -105,9 +105,16 @@ switch ($action) if ( $path == "/video/" ) { $tree = file_get_contents("textfiles/browseFolder-rec.txt"); } - else { + else if ( $path == "/mnt/media/Videos/" ) { $tree = file_get_contents("textfiles/browseFolder-vid.txt"); } + else if ( $path == "/mnt/media/Music/" ) { + $tree = file_get_contents("textfiles/browseFolder-aud.txt"); + } + else + { + $tree = file_get_contents("textfiles/browseFolder-rec.txt"); + } print $tree; break; diff --git a/bin/textfiles/browseAudio.txt b/bin/textfiles/browseAudio.txt deleted file mode 100644 index 2f91c4f..0000000 --- a/bin/textfiles/browseAudio.txt +++ /dev/null @@ -1,21 +0,0 @@ -{ - "list": - [ - { - "type": "folder", - "name": "album1", - "path": "/mnt/music/album1" - }, - { - "type": "folder", - "name": "album2", - "path": "/mnt/music/album2" - }, - { - "type": "audio", - "name": "audiofile.mp3", - "length": "3.30", - "path": "/mnt/music/audiofile.mp3" - } - ] -} diff --git a/bin/textfiles/browseFolder-aud.txt b/bin/textfiles/browseFolder-aud.txt new file mode 100644 index 0000000..e2e71be --- /dev/null +++ b/bin/textfiles/browseFolder-aud.txt @@ -0,0 +1,36 @@ +{ + "list": + [ + { + "type": "folder", + "name": "album1", + "path": "/mnt/music/album1" + }, + { + "type": "folder", + "name": "album2", + "path": "/mnt/music/album2" + }, + { + "type": "audio", + "name": "audiofile.mp3", + "number": "1", + "length": "3.30", + "path": "/mnt/music/audiofile.mp3" + }, + { + "type": "audio", + "name": "audiofile2.mp3", + "number": "2", + "length": "2.27", + "path": "/mnt/music/audiofile2.mp3" + }, + { + "type": "audio", + "name": "audiofile3.mp3", + "number": "3", + "length": "4.03", + "path": "/mnt/music/audiofile3.mp3" + } + ] +} diff --git a/bin/textfiles/getGlobals.txt b/bin/textfiles/getGlobals.txt index 87a9994..d4795e4 100644 --- a/bin/textfiles/getGlobals.txt +++ b/bin/textfiles/getGlobals.txt @@ -1,6 +1,6 @@ { "streamdev_server": "http://127.0.0.1:3000", "rec_path": "/video/", - "video_path": "/mnt/media/Video/", + "video_path": "/mnt/media/Videos/", "audio_path": "/mnt/media/Music/" } diff --git a/bin/textfiles/streamAudio.txt b/bin/textfiles/streamAudio.txt index 28cca73..a90d122 100644 --- a/bin/textfiles/streamAudio.txt +++ b/bin/textfiles/streamAudio.txt @@ -1,5 +1,5 @@ { - playlist: + track: [ { "file": "/istreamdev/playlist/track1.mp3" diff --git a/css/istreamdev.css b/css/istreamdev.css index ac58b7a..aa07a18 100644 --- a/css/istreamdev.css +++ b/css/istreamdev.css @@ -272,7 +272,7 @@ height: 20px; padding: 0; } -li.track .numberbox { +li.track a .numberbox { position: relative; width: 23px; height: 42px; @@ -283,7 +283,7 @@ margin-right: 3px; border-right: 1px solid #333333; -webkit-box-shadow: rgba(255,255,255,.1) 0 1px 0; } -li.track .number { +li.track a .number { position: absolute; color: #9c9ea0; top: 10px; @@ -295,7 +295,7 @@ left: 32px; padding-left: 4px; top: -3px; } -li.track div.timebox { +li.track a div.timebox { position: relative; width: 30px; height: 42px; @@ -306,7 +306,7 @@ margin-left: 3px; border-left: 1px solid #333333; -webkit-box-shadow: rgba(255,255,255,.1) 0 1px 0; } -li.track .time { +li.track a .time { position: absolute; color: #9c9ea0; top: 13px; diff --git a/index.html b/index.html index 66c8fa7..e674ebd 100644 --- a/index.html +++ b/index.html @@ -32,8 +32,8 @@ @@ -223,22 +223,6 @@ - -
-
- Home -

Audio

-
- -
- \ No newline at end of file diff --git a/js/istreamdev.js b/js/istreamdev.js index fc9247b..6e21e35 100644 --- a/js/istreamdev.js +++ b/js/istreamdev.js @@ -120,6 +120,14 @@ $('#video_but').tap(function(event) { gen_browser(video_path,browser,"Videos","vid"); return false; }); + +$('#audio_but').tap(function(event) { + event.preventDefault(); + json_start(this); + browser = 1; + gen_browser(audio_path,browser,"Audio","aud"); + return false; +}); // [/HOME SECTION] // [TV SECTION] @@ -389,11 +397,16 @@ function playvideo(session,name) { // [BROWSER SECTION] //buttons -$('ul[rel="filelist"] li.arrow a').tap(function(event) { +$('ul[rel="filelist"] li a').tap(function(event) { event.preventDefault(); json_start(this); var type = $(this).attr('rel'); + if ( type == 'audio' ) { + var name = $(this).find('span[class="tracktitle"]').html(); + } + else { var name = $(this).find('span[class="menuname"]').html(); + } var path = $(this).parents('div').find('span[rel="path"]').html(); var browser = $(this).parents('div').find('span[rel="currentbrowser"]').html(); var foldertype = $(this).parents('div').find('span[rel="foldertype"]').html(); @@ -412,6 +425,15 @@ $('ul[rel="filelist"] li.arrow a').tap(function(event) { { gen_streamvid(name,path); } + else if ( type == "rec" ) + { + gen_streamrec(name,path); + } + else if ( type == "audio" ) + { + var track = $(this).find('span[class="number"]').html(); + addplayer(path,name,track); + } return false; }); @@ -429,7 +451,7 @@ $('div[rel="browser"] #home_but').tap(function(event) { }); }); -//functions +//Generate browser div according to type function gen_browser(path,browser,name,foldertype) { browser_template = '
'; browser_template += ''; @@ -440,26 +462,32 @@ function gen_browser(path,browser,name,foldertype) { browser_template += ''; $('#jqt').append('
'), $('#browser'+browser).html(browser_template); - if ( path == rec_path || path == video_path ) { - toolbar = 'Home'; - if ( foldertype == 'rec' ){ + if ( path == rec_path || path == video_path || path == audio_path ) { + toolbar = 'Home'; + if ( foldertype == 'rec' ){ toolbar += '

' + name + '

'; - } - else { - toolbar += '

' + name + '

'; - } - $('#browser' + browser + ' div[class="toolbar"]').html(toolbar); + } + else if ( foldertype == 'vid' ){ + toolbar += '

' + name + '

'; + } + else if ( foldertype == 'aud' ){ + toolbar += '

' + name + '

'; + } + $('#browser' + browser + ' div[class="toolbar"]').html(toolbar); } else { - toolbar = 'Back'; - toolbar += 'Home'; - if ( foldertype == 'rec' ){ - toolbar += '

' + name + '

'; - } - else { - toolbar += '

' + name + '

'; - } - $('#browser' + browser + ' div[class="toolbar"]').html(toolbar); + toolbar = 'Back'; + toolbar += 'Home'; + if ( foldertype == 'rec' ){ + toolbar += '

' + name + '

'; + } + else if ( foldertype == 'vid' ){ + toolbar += '

' + name + '

'; + } + else if ( foldertype == 'aud' ){ + toolbar += '

' + name + '

'; + } + $('#browser' + browser + ' div[class="toolbar"]').html(toolbar); } var dataString = 'action=browseFolder&path='+path+'&browser=' + browser; $.getJSON("bin/backend.php", @@ -478,11 +506,34 @@ function gen_browser(path,browser,name,foldertype) { else if ( list.type == "video" ) { $("#browser" + browser).find('ul').append('
  • ' + list.name + '
  • '); } + else if ( list.type == "audio" ) { + $("#browser" + browser).find('ul').append('
  • ' + list.number + '
    ' + list.name + '
    ' + list.length +'
  • '); + } }); json_complete('#browser' + browser,'cube'); }); } +//Add audio player code when needed +function addplayer(path,name,track) { + $('#div_player').remove(); + $('#jqt').append('
    '); + //get playlist data + dataString = 'action=streamAudio&path=' + path + '&file=' + name; + $.getJSON("bin/backend.php", + dataString, + function(data) { + track = data.track; + playercode= "1; i-=1 ){ + playercode += "qtnext" + i + "='<" + escape(track[i].file) + ">' "; + } + playercode+= ">"; + $('#div_player').html(playercode); + hide_loader(); + $('#div_player player').play(); + }); +} // [/BROWSER SECTION] -- cgit v1.2.3