Phaser 3 audio distorted after playing a html5 video on IPAD - ipad

I'm working in an interactive e-learning game and I have several scenes, most of them with audio, video or both. The issue happens when I'm on IPAD and I'm in a scene that contains HTML5 video and I click back to a previous scene that contains audio, the audio will be distorted.
import chime from '../../audios/chime.mp3'
this.callerObj.audio('chime', chime)
this.callerObj.chime.play()
The video is like this:
<div tabindex="0" class="plyr plyr--full-ui plyr--video plyr--html5 plyr--pip-supported plyr--fullscreen-enabled plyr--captions-active plyr--paused">
<div class="plyr__video-wrapper">
<video id="lesson1p1" preload="auto">
<source src="whiteboard_background.mp4" type="video/mp4">
<source src="whiteboard_background.webm">
</video>
<div class="plyr__poster"></div>
</div>
<div class="plyr__captions"></div>
What can be corrupting the audio?
Is there any way to avoid this?

Well after checking some comments I tested this and it worked.
The issue is related to the audio manager and how it gets handled by the Html5 video.
this.item = document.getElementById('videoItem')
if(!!this.item){
this.item.src = ''
this.item.load()
}
After this I was able to play the clean audio

Related

issue with link on video in iOS when power is low

When playing an inline, autoplay video on an iPhone with a low battery, iOS requires the user to tap on the video to start it. (this makes sense... They want to save battery life by preventing videos from playin)
However, from what I can tell, this also leads to an adverse side effect: It is not possible to click through if the video has an href link.
Any workarounds to this?
Here's an idea of how I'm trying to do it:
<a href="http://www.link.com">
<video width="100%" autoplay loop muted playsinline>
<source src="https://source.mp4" preload type="video/mp4"></video>
</a>
add &rel=0 like this
src="https://source.mp4&rel=0"

HTML5 Video autoplay on iPhone

I have some kind of a strange problem. I try to create a website with a looped background video. The code looks like this one:
<video src="video/bg.mp4" style="z-index: -1;object-fit: cover;" poster="video/bg.jpg" autobuffer autoplay loop muted></video>
This works perfectly fine on most browsers (IE struggles with this object-fit thing but I don't mind) but on iPhone the video won't autoplay but on iPad it does. I already read the New Policies for iOS and I think I meet the requirements (otherwise iPad won't autoplay). I did some other testing:
Removing overlaying divs won't fix it
Removing z-index won't fix it
Wifi or Cellular doesn't make a difference
Video filesize doesn't make a difference, too
Am I doing it wrong or does iPhone simply won't autoplay videos and always requires interaction? I only care for iOS 10, I know that the requirements were different on iOS 9
Does playsinline attribute help?
Here's what I have:
<video autoplay loop muted playsinline class="video-background ">
<source src="videos/intro-video3.mp4" type="video/mp4">
</video>
See the comment on playsinline here: https://webkit.org/blog/6784/new-video-policies-for-ios/
iOs 10+ allow video autoplay inline. but you have to turn off "Low power mode" on your iPhone.
Here is the little hack to overcome all the struggles you have for video autoplay in a website:
Check video is playing or not.
Trigger video play on event like body click or touch.
Note: Some browsers don't let videos to autoplay unless the user interacts with the device.
So scripts to check whether video is playing is:
Object.defineProperty(HTMLMediaElement.prototype, 'playing', {
get: function () {
return !!(this.currentTime > 0 && !this.paused && !this.ended && this.readyState > 2);
}});
And then you can simply autoplay the video by attaching event listeners to the body:
$('body').on('click touchstart', function () {
const videoElement = document.getElementById('home_video');
if (videoElement.playing) {
// video is already playing so do nothing
}
else {
// video is not playing
// so play video now
videoElement.play();
}
});
Note: autoplay attribute is very basic which needs to be added to the video tag already other than these scripts.
You can see the working example with code here at this link:
How to autoplay video when the device is in low power mode / data saving mode / safari browser issue
I had a similar problem and I tried multiple solution. I solved it implementing 2 considerations.
Using dangerouslySetInnerHtml to embed the <video> code. For example:
<div dangerouslySetInnerHTML={{ __html: `
<video class="video-js" playsinline autoplay loop muted>
<source src="../video_path.mp4" type="video/mp4"/>
</video>`}}
/>
Resizing the video weight. I noticed my iPhone does not autoplay videos over 3 megabytes. So I used an online compressor tool (https://www.mp4compress.com/) to go from 4mb to less than 500kb
Also, thanks to #boltcoder for his guide: Autoplay muted HTML5 video using React on mobile (Safari / iOS 10+)
I had the same problem - the video not play on iOS. I tried all the code options "playsinline autoplay loop muted". The problem was the video I received was in the wrong mp4 codec. So what helped us, was to upload the video to Vimeo and download the HD Version again. The video is now playing on all mobile devices.
You could also try to use mpeg streamclip. Here is a screenclip of VLC - those are the correct settings. Hope someone does not have to spend 2 hours searching for the problem - happy holidays
Here is a simple solution to auto-play the video in IOS, I've already tried and it is perfectly working on IOS, Android, also on all the browsers on various platforms.
simply use (data-wf-ignore) and (data-object-fit) Attributes for the video and data-wf-ignore for the source tag..
You can see the working example with code here at this Snippet:
<video id="myVideo" autoplay="" muted="" playsinline="" data-wf-ignore="true" data-object-fit="cover">
<source src="https://www.w3schools.com/html/mov_bbb.mp4" data-wf-ignore="true" />
</video>

make autoplay work on IPAD and IPHONE

I have fullscreen video background, here is my code:
<div id="video-container">
<video id="video" autoplay loop>
<source src="ocean.mp4" type="video/mp4">
<source src="ocean.ogv" type="video/ogg">
<source src="ocean.webm" type="video/webm">
</video>
</div>
how you see it has autoplay attrubute, but on IPAD, IPHONE,etc.. it doesn't work untill you click on play button, but when I add poster attribute for poster image it works:
<video id="video" poster="poster.jpg" autoplay loop>
But I don't want with poster. Also I tried to use this js code but no result:
function startVideo(){
var myVideo = document.getElementById('video');
if ((myVideo.playing) || (myVideo.currentTime > 0)) {
// video is already playing
} else {
myVideo.play();
}
}
window.document.body.onload = startVideo;
I guess auto-play feature is not supported in iOS. Check this Apple documentation:
User Control of Downloads Over Cellular Networks
In Safari on iOS (for all devices, including iPad), where the user may
be on a cellular network and be charged per data unit, preload and
autoplay are disabled.
Here is the documentation link

iPhone plays embedded video fullscreen

i created a small website that includes a video with this code:
<video autoplay="autoplay">
<source src="inc/WEB_MASTER.mp4" type="video/mp4">
<source src="inc/WEB_MASTER_ios.m4v" type="video/mp4">
Your browser does not support the video tag.
</video>
When i load the page via my iPhone the video starts playing, but it does not play it in the part of the website, instead the iphone plays the video in fullscreen. How can i force the iphone to play the video in the respective area on the website?
Thanks.
The iPhone and iPod seem just about the only devices/browsers that force fullscreen video playback in Safari (and in apps that make use of its unmodified WebView)
You can work around this issue by simulating the playback by skimming the video instead of actually .play()'ing it.
I wrote a module that takes care of playing the video inline and synchronizing it to the audio (but it also works on videos without a sound track): iphone-inline-video
This question is answered here:
HTML5 inline video on iPhone vs iPad/Browser
Just add the webkit-playsinline attribute to the video tag. Works in iOS 4.0 and later:
<video id="player" width="120" height="60" webkit-playsinline>
Here is the official documentation for webkit-playsinline.

iOS: HTML5 video, continuous playback while remaining in fullscreen

I am currently developing an iPad app that aggregates various video feeds on the internet. Then using a UIWebView, some Javascript, a <video> tag, and the mp4 URL I can playback the video and the native iOS video controls appear. This all works great.
Additionally by subscribing to the video 'end' event, I can queue up another video to play after the one you were watching finishes. This also works great, EXCEPT if you were in fullscreen when the next video starts to play, you are taken out of it and back to the app!
Does anyone know a way that I can persist fullscreen HTML5 video in iOS when a new video is loaded?
The following worked for me on mobile safari on an iPod touch. Listen for the end event and change the source of the current video tag to the new video.
<html>
<body>
<video id="myVideo" src="http://shapeshed.com/examples/HTML5-video-element/video/320x240.m4v" autoplay>
</video>
<script>
document.getElementById('myVideo').addEventListener('ended',myHandler,false);
function myHandler(e) {
if(!e) { e = window.event; }
// What you want to do after the event
document.getElementById('myVideo').src='http://movies.apple.com/media/us/html5/showcase/2010/demos/apple-html5-demo-tron_legacy-us-20100601_r848-2cie.mov';
}
</script>
</body>
</html>

Resources