0

I'm looking for a solution to play mp3 audio and video in a php server. I am using the following code to play mp3 files, but getting an issue when I play mp3 files.

Code:

  $path =$test['url'];

  $show='<embed src=" ../songs/$path" width="346" height="258"> </embed>';
  echo ($show);
  <video width="320" height="240" controls click>
  </video>
Pieter Goosen
  • 9,768
  • 5
  • 35
  • 55
ankur patel
  • 1
  • 1
  • 5
  • What Kind of error You Getting..? and have you checked the path properly.? – Bhumin Vadalia Aug 23 '14 at 05:16
  • path properly done but not play mp3 file and properly fetch data – ankur patel Aug 23 '14 at 05:18
  • 2
    This does not seem like a php question (unless your problem is reaching the mp3 file)... it's an HTML question. Try with a static html page and see if you can make it work. Have a look at http://stackoverflow.com/questions/8641355/playing-audio-in-html – Frazz Aug 23 '14 at 05:23
  • Also check whether your Browser supports the sound format or not. – Bhumin Vadalia Aug 23 '14 at 05:24
  • sound format supported all browser.. – ankur patel Aug 23 '14 at 06:12
  • $test['url']; this code to print fetch data file but issue in play mp3 – ankur patel Aug 23 '14 at 06:13
  • @ankurpatel No codec is supported by all browsers, and certainly not MP3. MP3 support in browsers is usually platform specific because the browser makers don't want to pay the licensing fees. Also you aren't trying to play audio/video with PHP, you're trying to use HTML 5 which has nothing to do with PHP. – Brad Aug 23 '14 at 06:20
  • @brad u asking mp3 play only for html5 code not use php code – ankur patel Aug 23 '14 at 06:35
  • @ankurpatel if you develop web applications... I suggest you start thinking that there is absolutely no feature which is supported by all browsers, all versions, all platforms. It's better for yourself, your work and your users. Yes, there are standards... and yes, there are implementations. But never dream everything will work everywhere or you'll have a bad time when you wake up ;) – Frazz Aug 23 '14 at 07:11

2 Answers2

0

Try These Html Tags.

<audio controls>
      <source src="horse.ogg" type="audio/ogg">
      <source src="horse.mp3" type="audio/mpeg">
    </audio>

  <video width="320" height="240" controls>
      <source src="movie.mp4" type="video/mp4">
      <source src="movie.ogg" type="video/ogg">
    </video>  
Edwin Thomas
  • 1,186
  • 2
  • 18
  • 31
0

You can do this with an embedded object:

<embed src="music.mp3" width="145" height="60" autostart="true"></embed>

Change the file name to where ever it is and away to go. There are a whole bunch of options for this sort of thing, but the above should get you going at least.

Brad
  • 159,648
  • 54
  • 349
  • 530
H.Roshan
  • 21
  • 2
  • 6