Play specific m4a formats

I searched for a while on this subject, but found nothing. I have to upload a certain number of .m4a files to the web page, each of which is inside a separate player. I found and implemented jplayer that claims to handle the format. I decided to use the default flash reserve to avoid lagging incompatibilities. The m4a file example provided in the jplayer examples ( http://www.jplayer.org/audio/m4a/TSP-01-Cro_magnon_man.m4a ) works fine, while I was unable to play any of the files that Eat me.

I ran the file unix command for all files. The jplayer example file returns:

ISO Media, MPEG v4 system, version 2

Broken files return one of the following values:

ISO Media, MPEG v4 system, 3GPP ISO Media, MPEG v4 system, version 1 ISO Media, MPEG v4 system, iTunes AAC-LC

I am downloading audio files with the following PHP controller code. I need to do this in order to β€œrewrite” the URLs and hide the actual file URI.

 header('Content-Type: audio/mp4'); header('Content-Disposition: inline; filename=xxxxxxxxxxTrack'.$id.'.m4a'); echo file_get_contents(MVC::siteRoot().'/'.$filename); 

(MVC :: siteRoot () returns the physical directory in which the script is stored.) I also tried Content-Type: audio/mp4a-latm again to no avail. I download jplayer with the following code:

 $('.jp-jplayer').each(function() { $(this).jPlayer({ ready: function () { console.log($(this).attr('data-src')); $(this).jPlayer("setMedia", { m4a: $(this).attr('data-src') }); $("#insp").jPlayerInspector({jPlayer:$(this)}); }, swfPath: "<?=MVC::httpRoot();?>/gui/swf/Jplayer.swf", supplied: 'm4a', wmode: 'window', solution:"flash", errorAlerts:true, warningAlerts:true, cssSelectorAncestor: '#' + $(this).attr('id').replace('jquery_jplayer','jp_container') }); }); 

On the DOM side, for each audio file identified by the progressive number $ i, this happens:

 <div id="jquery_jplayer_<?=$i?>" class="jp-jplayer" data-src="<?=MVC::httpRoot()?>/get/audio/<?=$traccia['audioid']?>"></div> <div id="jp_container_<?=$i?>" class="jp-audio">[...] 

Players seem to load correctly, the DOM rebuilds according to jplayer, but nothing happens when the play button is pressed. There is no error on the network, the file has been delivered correctly, but the contents are not playing and no warnings or errors have been issued. In fact, I only get to listen to the files, download them and open them in QuickTime, since even Chrome will not play them. Safari, on the other hand, will happily download and play files, but not inside the website. Unfortunately, I cannot directly control the contents of the downloaded files, since they come from the iOS / Android application, and for some reason the client requested the .m4a format. Has anyone encountered a similar problem?

+4
source share
1 answer
  • problems with DRM

  • MIME Type

Your domain server must specify the correct MIME type (content type) for all multimedia URLs.

Failure to specify the correct MIME type will stop the media from working in some HTML5 browsers. This is a common cause of problems that affect only Firefox and Opera. Other browsers are less strict, but the MIME type should always be checked so that it is correct if you have problems playing media in any browser.

Types of Multimedia MIME

  MP3: audio/mpeg MP4: audio/mp4 video/mp4 OGG: audio/ogg video/ogg WebM: audio/webm video/webm WAV: audio/wav 

If you use a common extension for audio and video media such as audio.mp4 and video.mp4, just use the MIME video version for them. i.e. video / mp 4

On Apache servers, you can use the .htaccess file to set the MIME type based on the file extension:

 # AddType TYPE/SUBTYPE EXTENSION AddType audio/mpeg mp3 AddType audio/mp4 m4a AddType audio/ogg ogg AddType audio/ogg oga AddType audio/webm webma AddType audio/wav wav AddType video/mp4 mp4 AddType video/mp4 m4v AddType video/ogg ogv AddType video/webm webm AddType video/webm webmv 

3. Byte range requests

The server must enable range requests. This is easy to verify if you answered that your server response includes Accept-Ranges in the header. Most HTML5 browsers allow you to search for new file positions at boot time, so the server must allow it to request a new range.

Inability to accept bytes. Range queries pose problems in some HTML5 browsers. Often a duration cannot be read from a file, as some formats require that the beginning and end of a file be read in order to know its duration. Chrome is usually the browser that has most problems if the range request is not enabled on the server, but all browsers will have some kind of problem, even if this is only what you need to wait for all media to load before jumping close to the end.

This issue is known to affect Jetty 6 servers with their default configuration.

https://groups.google.com/d/msg/jplayer/nSM2UmnSKKA/bC-l3k0pCPMJ

  • Protect your media

Be careful when trying to restrict access to your media files. The media URL should be accessible via the Internet by the user, and his response should be in the expected format.

Using a server response to disable the local media cache can cause problems with some HTML5 browsers. This can lead to an unknown media duration, which will be displayed as NaN in jPlayer duration.

If you do some magic on the backend to make it more secure, make sure that you accept the range byte requests described above.

Yes, I just copied / pasted faq, I don’t know anything about it.

+2
source

Source: https://habr.com/ru/post/1436165/


All Articles