How to play m4a audio file in html audio player in MAC SAFARI browser - safari

I have implemented a web application which uses html audio player. We will be having two type of audio files
mp3
m4a
both files are playing fine in windows chrome, edge and firefox.
Regarding m4a file in safari browser it was throwing Error instead of playing.We tried with below cases
Case 1: Added Mime extension and audio type to "audio/mp4".
Case 2: Added audio type to "audio/x-m4a".
Case 3: Does not provided audio type.
<audio controls><source src="Audio.m4a" type="audio/mp4"></audio>

This would vary depending on which OS version and browser versions you have, but the following works on MacOS Catalina in both Safari and Chrome.
<audio controls>
<source src="test.m4a" type="audio/x-m4a">
<source src="test.mp3" type="audio/mp3">
Your browser does not support the audio tag.
</audio>
Note the "audio/x-m4a" type for .m4a files.
You can check for audio player type compatibility by grabbing the HTMLAudioElement and calling:
console.log("Can play m4a:" + audioElement.canPlayType('audio/x-m4a'));

Am closing this task with answer as M4A cannot be played in MAC Safari browser in html audio player tag after trying out all possible solutions across different sites

Related

Problem with playing large (long) audio files in Safari via HTML tag

I cannot make Safari play large audio files using audio tag (in Chrome it works as desired). Is there any limitation in Safari? How to solve the problem of playing too long audio?
This is how I use the tag:
<audio src="test.mp3" contros></audio>

Playing base64 webm audio on Safari

I've tried a bunch of things to no avail. Setting the src of an audio element to the following base64 webm dataurl snippet and playing it works in most browsers, but is failing in Safari. Pasting the snippet in the location bar even works in Chrome.
https://gist.github.com/mayorbyrne/99e47f58eefcfe72e84e3e320d136c2c#file-gistfile1-txt
I am able to play a base64 encoded mp3 dataurl, as the following fiddle I found in another response works: https://www.jsfiddle.net/apo299od -- In addition, I've tried replacing the beginning of the snippet data:audio/webm with data:audio/mp3 (works in Chrome, etc), and that moves me further along, but the audio doesn't actually play, it just flashes the audio symbol in the browser for a quick second.
Just wondering if I am spinning my wheels here, or if there is a way to get this snippet playing in an audio element on Safari.
Safari on iOS doesn't support the Vorbis / Opus audio codecs in WebM and on desktop only via third-party extensions like the VLC Web Browser plugin. Safari on iOS 11+ / macOS High Sierra+ can play Opus only if it's in a CAF container.
Note: Safari on iOS supports low-complexity AAC audio, MP3 audio, AIF audio, WAVE audio, and baseline profile MPEG-4 video. Safari on the desktop (Mac OS X and Windows) supports all media supported by the installed version of QuickTime, including any installed third-party codecs
source: https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/AudioandVideoTagBasics/AudioandVideoTagBasics.html
Safari can support Ogg Opus files with WebAssembly decoding. You can see the demo and code below. Not as simple as using an <audio> element, but you will get faster, low-latency playback using the Web Audio API:
https://github.com/AnthumChris/fetch-stream-audio

HTML Video: Is it possible to fallback to HLS for lack of DASH/Webm-VP9 support on Safari, or how do I support both Webm and H264 on DASH?

I'm trying to serve some video content from a webserver, with the intention of supporting a reasonably wide set of browsers.
For iOS, as far as I can tell the way to go is to use HLS (HTTP Live Streaming) whereas on the desktop (and I guess Android?) MPEG-DASH is the state of the art. As a fallback I can provide a few static videos.
I've got this working on iOS with HLS and Chrome, Firefox, Opera, and Edge on desktop, but Safari on Mac just shows an activity spinner when I press play. As far as I can tell, this is because Safari tries and fails to use DASH as the playback method despite lack of Webm support and HLS being listed first.
For MPEG-DASH I have used Webm with VP9 and Opus, and my <video> tag looks something like this:
<video controls style="display:inline-block;max-width:174.22vh;max-height:98vh;width:98vw;height:55.125vw;background-color:#ccc;" preload="auto" poster="my-preview-image.jpg" data-dashjs-player>
<source src="myvideo/hls/playlist.m3u8" type="application/x-mpegURL">
<source src="myvideo/dash/manifest.mpd" type="application/dash+xml">
<source src="myvideo/myvideo-vp9.webm" type="video/webm; codecs=vp9,opus">
<source src="myvideo/myvideo-vp8.webm" type="video/webm; codecs=vp8,vorbis">
<source src="myvideo/myvideo-h264.m4v" type="video/mp4; codecs=h264,aac">
</video>
And I'm just importing the reference DASH implementation using
<script src="dash.all.min.js"></script>
I'm generating the HLS and DASH streams using ffmpeg from a high-quality master video exported from Final Cut Pro. The static Webm fallback files are also generated using ffmpeg while the H264 static fallback file is a lower-bitrate export from Final Cut Pro.
Is there a way I can either:
Tell DASH to respect the order of the sources and not jump ahead of the HLS stream
Or, not kick in if video/webm; codecs=vp9,opus is not supported by the browser.
Finally, if neither of those are possible, can I support multiple different codecs simultaneously with DASH? i.e. can I provide both VP9 and H264 DASH streams and have it pick VP9 over H264 where supported and otherwise fall back to H264 (higher bitrate or lower quality)? How would I go about producing that stream data?
From what you have shared, your browser will use the dashjs player when it encounters the video tag with the 'data-dashjs-player' attribute and the DASH player will focus on the formats it supports which do not include HLS.
As a crude solution you could check whether the browser can play HLS and use the native video tag if it can and your DASH player if it does not. Checking for HLS playback is a little undefined but the below approach appears to work at this time:
document.createElement('video').canPlayType('application/vnd.apple.mpegURL')
This should return 'maybe' on a browser which can play HLS (only Safari at this time AFAIK) and nothing if it can't - I just tested it on Safari and Chrome and it seems to behave like this.
Its worth noting that dash.js should be able to play MPEG DASH files on safari so it may be worth looking into the console or logs to try to find why it will not play your DASH video.

Html5 videos not displaying

I have a couple of videos uploaded to Hostgator (my hosting service), and I'm displaying them on a page with the HTML5 video player. The video is there (I know because I can hear the audio,) but in Chrome all I see is a black screen, and in Firefox it won't play at all, just says "No video with supported format and MIME type found."
The video files are both ones I had to convert from a .mov to a .mp4. But they are all mp4 files.
When I download the videos again from Hostgator, they are normal, so I don't think anything is wrong strictly with the files themselves.
What could be going wrong here? Thank in advance.
I suppose the issue is in wrong codec. It should be h.264 for MP4 file.
Source with instruction http://www.freemake.com/how_to/how_to_create_and_embed_html5_video
Web video is complicated, most browsers support different video formats (codecs). To be compatible with all browsers you need every video in 3 different file formats: MP4, OGG, WEBM.
For maximum compatibility, here’s what your video workflow will look
like:
Make one version that uses WebM (VP8 + Vorbis).
Make another version that uses H.264 baseline video and AAC “low complexity” audio in an MP4 container.
Make another version that uses Theora video and Vorbis audio in an Ogg container.
Link to all three video files from a single element, and fall back to a Flash-based video player.
<video width="320" height="240" controls>
<source src="video.mp4" type="video/mp4">
<source src="video.webm" type="video/webm">
<source src="video.ogv" type="video/ogg">
</video>
Source: http://diveintohtml5.info/video.html#what-works

IE10 not playing a video when using the <video> tag, but plays it when requesting the video directly

I have a webpage with a tag on it with the following markup:
<video width="456" height="360" controls autoplay>
<source src="Movies/Intro.mp4" type="video/mp4" />
<source src="Movies/Intro_H264.webm" type='video/webm; codecs="vp8.0, vorbis"'/>
<source src="Movies/Intro_H264.ogg" type='video/ogg; codecs="theora, vorbis"'/>
</video>
If I visit this page in IE10 it renders the video player but with an error message that reads: "Error: unsupported video type of invalid file path"
But what's odd is if I right-click on the video box and choose, Copy video URL, and then open a new tab in IE and paste in the direct URL to the video file (Movies/Intro.mp4) it plays in the browser without issue.
Also, I can visit the page using Chrome and it plays the MP4 video from the webpage without issue. All that to say, I don't think there's any issue with the video file itself or the encoding, but why is IE 10 not playing the video when it's in the tag, but it is playing it when requesting the video directly?
Any insights?
Thanks
I would check whether the mime-type is correctly being returned for the file.
Chrome will play correctly regardless of the MIME Type returned.
To check:
Press F12 to display the IE Tools Window/Pane.
Go to the Network Tab
Click Start Capturing
Browse to the page in question
Find the mp4 line
If the Type is displayed as application/octect-stream then this is your issue.
I had the same issue with IE 11 and the problem was the content type was application/octect-stream as stated by csmith. I was serving my videos from Azure storage and apparently that is the default content type.
You can change the type with Azure storage or using Azure api as shown in the post
Set Content-type of media files stored on Blob
Here is a guide for people on Amazon cloud (I did not test it)
Changing content type for Amazon
Make sure you set the web server to use MIME type video/mp4 for .mp4. I accidentally set .mp4 to use MIME type video/mpeg, the video plays in Chrome, but not in IE11.
I had this same issue which was a real pain in the ass. My solution was actually quite simple (after searching on the internet for about 4 hours).
Add this line (specific for IE) to your .htaccess file.
AddType video/mp4 .mp4 .m4v
When you paste the URL to your browser it doesn't use HTML5 player anymore, so it doesn't say that it is really a supported file; only that the file path should be valid.
According to wikipedia, IE10 supports (not only) H.264 for video and AAC for audio - these are very common formats for mp4 container. Chrome's support is much wider (video- and audio-wise).
The problem is that the Intro.mp4 file might have different formats altogether (the file could by just renamed or created using unsupported formats).
I'd look into the file using properties->details or third party programs (for example Media Info).
I don't think it is IE10's issue. The only similar one I've found is when the user was too specific using unsupported format of used codecs ([...] type='video/mp4; codecs="H.264, AAC"' [...]).
Now it is very easy to update mime type for your videos on amazon s3,
Just login and navigate to your file, under preferences you will see metadata, there you can edit content-type
Save it and reload your page.
If it directly plays find when you put the .mp4 URL into the browser make sure it's not running with the Quicktime plugin which you may have installed (especially if you use iTunes). Right click on the successfully playing video to rule that out. If it comes up with menu items related to Quicktime you may want to disable Quicktime plugin in adins and continue troubleshooting.
Sample MP4 video: http://www.w3schools.com/html/mov_bbb.mp4