Author Topic: Playing mp3's from database in IE and Explorer using html 5  (Read 1877 times)

mt81832

  • Guest
Hi I am trying to find a fix for playing mp3's in IE and Safari.  This is the code below.  The songs work in Firefox, Google but not in the others.  The songs are in a database which I use php and mysqli, so it is loading the album images and media.  If I use   <audio controls="controls"> <source src="audio.mp3" type="audio/mp3"><source src="audio.ogg" type="audio/ogg"> nothing plays.  The website is cccc-praiseteam.com/artist1.php.   I am using the source code:<source src="assets/audio/"<?php echo $row_Product_Details['song_audio']; ?>"</source>.  Should the type="audio/mp3" go here:<source src="assets/audio/"<?php echo $row_Product_Details['song_audio']; ?>type="audio/mp3"</source>

<div class="coverdisplay">
<img src="assets/images/<?php echo $row_Product_Details['song_image']; ?>" />
</div>
<div class="productdata">
<h2>Music:</h2>
<p><br /><h6>Song:</h6> <?php echo $row_Product_Details['song_name']; ?></p>
<p><h6>Artist:</h6> <?php echo $row_Product_Details['artist_name']; ?></p>
<p><h6>Genre:</h6> <?php echo $row_Product_Details['song_genre']; ?></p>
<p><h6>Description:</h6> <?php echo $row_Product_Details['song_description']; ?></p>
<h6>Audio:</h6><p class="audiosamp"> <audio controls="controls">
<source src="assets/audio/"<?php echo $row_Product_Details['song_audio']; ?>"</source>
<source src="assets/audio/"<?php echo $row_Product_Details['song_audio_2'];?>"</source>
Your browser does not support the audio element for sampling.<br>

</audio>

Thanks

JennaSetticasi

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 492
Re: Playing mp3's from database in IE and Explorer using html 5
« Reply #1 on: May 07, 2014, 06:20:27 am »
I do believe the correct way to embed HTML5 audio is:

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

The problem is that different browsers support different file formats. However, the mp3 format should work for IE and Safari as far as I know.

You could also try combining the audio and embed tags:

<audio controls>
  <source src="myfile.mp3" type="audio/mpeg">
  <embed height="50" width="100" src="myfile.mp3">
</audio>
Jenna Setticasi
The Art Institute of Pittsburgh | Online Division
Associate Professor, Web Design and Interactive Media

mt81832

  • Guest
Re: Playing mp3's from database in IE and Explorer using html 5
« Reply #2 on: May 10, 2014, 06:55:18 pm »
Hello,

I tried adding the type="audio/mpeg" then the songs won't even play in firefox or google chrome.  What am I doing wrong.  The songs come from the online database.

Thanks,

JennaSetticasi

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 492
Re: Playing mp3's from database in IE and Explorer using html 5
« Reply #3 on: May 13, 2014, 05:47:52 am »
You could try embedding a normal MP3 (not from the database) in one of your pages and see if that works. Then you will know if it is the code or the database results that are the issue. You can also view source in your browser to see if the database results are returning properly.
Jenna Setticasi
The Art Institute of Pittsburgh | Online Division
Associate Professor, Web Design and Interactive Media