DCHP
DCHP

Reputation: 1131

Playing a file from computer through browser

I have a website working locally on xampp on my computer which plays mp3 files and i want to try and get it working straight from my computer example i had it setup as the following, to access a mp3 file on the server.

mp3:"http://example.co.uk/folder/1/INSTRUMENTAL/arsonists - instrumental.mp3"

this works great and my player will play the mp3 through jplayer, what i am trying to do now is set it up to play files from my local folder.

i can access the folder with the following.

'../../../../../../Users/dave/mix tunes/New folder/1/INSTRUMENTAL/'

i am then looping through all the files with this.

if ($handle = opendir('../../../../../../Users/dave/mix tunes/New folder/1/INSTRUMENTAL/')) {
    while (false !== ($entry = readdir($handle))) {     

    $file = "/../../../../../../Users/dave/mix tunes/New folder/1/INSTRUMENTAL/".$entry;

              $playlist .= '{

            title:"'.substr($tname, 0, -4).'",

            mp3:"'.$file.'"

             },'; 

    }
    closedir($handle);
}

so i end up with the following snippet if i view my source code.

},{

            title:"Apollo Four Forty - Lost In Space (Theme)",

            mp3:"/../../../../../../Users/dave/mix tunes/New folder/1/INSTRUMENTAL/Apollo Four Forty - Lost In Space (Theme).mp3"

             },{

            title:"arsonists - instrumental",

            mp3:"/../../../../../../Users/dave/mix tunes/New folder/1/INSTRUMENTAL/arsonists - instrumental.mp3"

             },{

The player obviously doesn't play the files in the player.

Can anyone help me with this.

Thanks

ok found a way to play the file in the browser.

file:///Users/dave/mix%20tunes/New%20folder/1/INSTRUMENTAL/Busta%20Rhymes%20-%20Turn%20It%20Up%20(remix)-Fire%20It%20Up%20(Instrumental).mp3

but it still wont play through jplayer???

Upvotes: 0

Views: 719

Answers (1)

Lloyd
Lloyd

Reputation: 8396

Which browser are you using? Which solution is your jPlayer using, Flash or HTML? If Flash, then be aware:

Attempting to run jPlayer locally on your computer will generate Flash security violations and you would need to enable the local file access using the Flash Settings Manager.

Taken from: http://www.jplayer.org/latest/developer-guide/#jPlayer-flash-security

Upvotes: 1

Related Questions