2

I have made a mp3 player. Which plays only src determined files. But I need it should also play those .mp3 file which is in my computer local drive. But only this c://fakepath... stop my effort.

Can anybody solve this problem. So that I can solve such problem for my next video player.

Thanks

Gautam Kumar
  • 48
  • 1
  • 6

4 Answers4

0

Local files can't be referenced from the web. However if you have the file on your computer and access it with file://something, it should be able to access relative urls.

Community
  • 1
  • 1
NoBugs
  • 9,310
  • 13
  • 80
  • 146
  • Sorry, for more clarification, a simple question. How can I play computer local .mp3 file from browser through "input type='file'" through javascript. :) – Gautam Kumar Apr 05 '13 at 06:10
0

I found an answer here.

You can choose a file with input tag and play it with audio tag.

Jeff
  • 817
  • 6
  • 12
-1

If you want to Use Javascript

Get your audio element and call the play():

document.getElementById('audiotag').play();

Check example: http://www.storiesinflight.com/html5/audio.html.
This site has complete details.

Nagesh Salunke
  • 1,278
  • 3
  • 14
  • 37
  • Sorry, for more clarification, a simple question. How can I play computer local .mp3 file from browser through "input type='file'" through javascript. :) – Gautam Kumar Apr 05 '13 at 06:17
-1

Not sure exactly what you're looking for, but you could try something like:

<audio id="myaudio" src="file://my/dir/file.mp3" preload="auto"></audio>
<a href="javascript:play_sound();">test audio</a>
<script type="text/javascript">

  function play_sound() {
    document.getElementById('myaudio').play();
  }

</script>
jml
  • 1,745
  • 6
  • 29
  • 55