Skip to content
This repository has been archived by the owner on Nov 20, 2021. It is now read-only.

Can't toggle mute/sound #56

Open
giannoudak opened this issue Jun 30, 2016 · 7 comments
Open

Can't toggle mute/sound #56

giannoudak opened this issue Jun 30, 2016 · 7 comments

Comments

@giannoudak
Copy link

Hello, i use your solution to autoplay inline a video with the muted option set, but i can't figure out how i can play video sound afterwards.

i try to set video.muted = true/false on a button click but nothing actually happens. How can i trigger video button from an external click?

@fregante
Copy link
Owner

fregante commented Jun 30, 2016

Last week I started some work to do exactly that, but it's not finished yet and I don't remember how well it worked: https://github.com/bfred-it/iphone-inline-video/tree/mute-toggle-test

For now you'll just have to have to separate <video> elements, one muted and the other one to replace it with

@giannoudak
Copy link
Author

At first thanks for your immediate reply! this was really helpfull!

For your workaround you mention with two <video> elements, how they can be synchronized? As far i understand, say that we autoplay muted the one video, and with click on a sound button we trigger play for the other video on the first's currentTime. I'm on the right direction?

Also, actually do you have an estimation on that branch completion?

@fregante
Copy link
Owner

Something like this:

    //audioVideo.load() // not necessary, but may make the jump faster
    mutedVideo.onclick = function () {
        audioVideo.currentTime = mutedVideo.currentTime;
        mutedVideo.pause();
        audioVideo.play();
    }

This is probably going to take a bit to actually start playing, but maybe you can jumpstart that with the first line.

Not sure about when I can look into that, it's unlikely to be done before the end of next week.

@GordanRatkovic
Copy link

Any progress on this? I noticed you have an active branch for the mute-toggle feature.

@fregante fregante mentioned this issue Feb 5, 2017
13 tasks
@reidblomquist
Copy link

+1 would love to see this feature added

@windchime18
Copy link

windchime18 commented Mar 20, 2017

i think playing two videos simultaneously is not possible depending on the iOS version. I have also tried it and it worked on iOS9 but not on iOS10 Playing multiple videos side by side iOS #92

@fregante fregante changed the title Trigger sound for muted autoplay inline video Can't toggle mute/sound Mar 20, 2017
@windchime18
Copy link

windchime18 commented Mar 23, 2017

I think i have found a possible work around on this problem. you can use this code
you should have a two videos. then a button to activate the function enable the 2nd video with sounds.

var video = document.getElementById("video_without_audio"); 
var myVideo = document.getElementById("video_with_audio");

function enableSound() {
    myVideo.load();
    myVideo.play();
    myVideo.pause();
    video.pause();
    $("#video_without_audio").css("display", "none");
    $("#video_with_audio").css("display", "block");
}

myVideo.addEventListener("canplay", function() {
// console.log(" canplay: before = " + myVideo.currentTime);
myVideo.currentTime = video.currentTime;
// console.log(" canplay: after = " + myVideo.currentTime);

if( myVideo.currentTime < 1 ) {
	myVideo.play();
}
else {
	setTimeout(checkStarted, 500);
}
    
}, false);

function checkStarted()
{ 
console.log("check started");
   myVideo.play();
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants