How to insert an audio/mp3 using Cakephp?

Asked

Viewed 178 times

1

I’m trying to view this:

 <?php echo $this->Html->media('musica.mp3'); ?>

but nothing appears

1 answer

1


Following the documentation of that helper the exit would be like this:

<?php echo $this->Html->media('audio.mp3'); ?>

 // saida
 <audio src="/files/audio.mp3"></audio>

 <?php echo $this->Html->media('video.mp4', array(
     'fullBase' => true,
     'text' => 'Fallback text'
 )); ?>

 // saida
 <video src="http://www.somehost.com/files/video.mp4">Fallback text</video>

<?php echo $this->Html->media(
     array(
         'video.mp4',
         array(
             'src' => 'video.ogg',
             'type' => "video/ogg; codecs='theora, vorbis'"
         )
     ),
     array('autoplay')
 ); ?>

 // saida
 <video autoplay="autoplay">
     <source src="/files/video.mp4" type="video/mp4"/>
     <source src="/files/video.ogg" type="video/ogg; codecs='theora, vorbis'"/>
 </video>

There is the possibility that your browser is not rendering, see inside the html to see if it is printing some tag.

  • It’s rendering, it just doesn’t show up in the view.

  • check if the audio path is right, see if your browser has compatibility with the tag, pass the text parameter inside the array, if you view the text it is because your browser is not compatible

  • I’ve already done it, it plays if I use pure html. The question is why "$this->Html->media" doesn’t work...

  • As for the path Cake automatically picks up the folder "files".

Browser other questions tagged

You are not signed in. Login or sign up in order to post.