Audio is not played on mobile chrome - javascript

I have an audio element with a mp3 src that is being played successfully on chrome desktop but when I try to play it on a mobile chrome browser it does not play.
<audio id="my_sound">
<source src="sounds/alarm.mp3">
</audio>
The invoke code:
$("#my_sound").get(0).play();
The audio is played when a view is finished loading and not as a onclick event.
any idea what can I do?

Related

HTML video tag's autoplay property has no effect in chrome if click Refresh button?

I need to start playing video file automatically when my page is opened. I use tag for that. Everything is Ok with Firefox (my version is 50, Windows 10). But if I open this page in Chrome (my version is 66.0.3359.139, Windows 10) it does not starts playing video. If I click Refresh button it also doesn't play it. But if I press F5 or Ctrl+F5 it starts playing.
Example page: http://136.243.19.144/test-video.php
Video Code:
<video autoplay loop controls>
<source src="http://136.243.19.144/v/230518/4XFq546l.mp4" type="video/mp4"/>
</video>
What is wrong with this simple code?
EDIT:
Solution: Just add "mute" attribute to video tag.
Found in Video loop autoplay won't work on Chrome/safari (webkit bug)

How to get html5 video work on android 4.3

I have an app where some videos are placed using html5 video tag. It works fine in Chrome Browser (desktop), but does not play on android (tested on tablet with android 4.3). It just shows player with black background (no video).
I have tested with my Nexus 5 (android 5.1.1) and it works fine.
Î have tried this html:
<video id="video" controls>
<source src="../videos/portfolio.mp4">
<img src="../images/pf_preview.png" width="100%"/>
Your browser does not support HTML5 video.
</video>
<script>var video = document.getElementById('video');
video.addEventListener('click',function(){
video.play();
},false); </script>
I deleted type of video, and put the js code to play video manually. But it still fails to play.
Any ideas how to fix it?
Best

Audio play() not working on Android 4.4 mobile devices

I am trying to play a simple audio file via javascript on page load which works on browsers and mobile devices but same not working with android 4.4 version.
Below is the code snippet:
<audio controls id="player">
<source src="testaudio.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<script>
var audiofile = document.getElementById("player")[0];
audiofile.load();
audiofile.play();
</script>
Please let me know if I am missing something.
Thanks in advance.

Mobile auto play live streaming

We are developing an application that needs to auto play a live streaming video in mobile. At the moment we been only able to start the streaming by clicking over the video.
How to auto play live streaming video on mobile (inside the html)?
How to prevent the click over the video opening the mobile video player?
I've seen some articles saying neither are possible but both works on this site: webcams.com (adult)
Thanks,
<video autoplay = "autoplay" or "" (empty string) >
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
autoplay Instructs the UA to automatically begin playback of the audio stream as soon as it can do so without stopping.
The <video> tag is supported in Internet Explorer 9+, Firefox, Opera, Chrome, and Safari.
I have the same requirement before.
As I know, it is disable to auto play in some mobile browsers.
If your case can accept no auido, and then you can refer this page.
It uses canvas and WebSocket to draw the video.

Audio - Chrome Mobile - Android

I cannot play audio with Chrome Mobile on Android. Is it restricted from playing audio (OGG)?
So, I've an HTML document. Inside, is the following audio tag:
<audio id="audiotag1" src="beep.ogg" preload="auto"></audio>
I also trigger the audio to play with JS:
document.getElementById('audiotag1').play();
The audio plays fine in Chrome desktop but doesn't play at all in Chrome Mobile. Are there some restrictions/flags I should know?
Chrome for Android requires a user-gesture to play the sound audio file. Make sure that your play invocation is on an event such as click.
Yes only Mozilla I believe really support that format on mobile

Categories

Resources