0

I'm having an issue making the Volume to 0 when the deviceready is triggered. Currently my codes are

<div id="dvVideo">
    <video webkit-playsinline playsinline id="videoPlayback" poster="#">
        <source src="#" type="video/mp4">
    </video>
</div>

and scripts are

var vidcont = document.getElementById('dvVideo');

        document.addEventListener('deviceready', function() {
            vidcont.style.display = "none";
            vid.src = "http://linktovideo.com/test.mp4";
            vid.load();
            vid.play();
            vid.volume = 0.0;
        });

What am I trying to achieve is that the video should preload before a button is clicked to play the video and it has to be hidden. What I'm currently doing is playing the video in the background, while the it is displayed as none, then when the button is pressed, it will displayed as block and video.currentTime is set to 0.0. Which makes the video seems to load fast.

Is there any alternative way to do this? I'm thinking of the preload="metadata" etc. but can't seem to get it to work. Can someone explain on the preload thing?

Edit: It works fine on any browsers but I just can't make it work on Android.

Shukri Damit
  • 83
  • 2
  • 11
  • Android won't let you autoplay a video unless it is (a) muted and (b) visible. One possible solution (depending on size of video) is https://stackoverflow.com/questions/18251632/another-force-chrome-to-fully-buffer-mp4-video/18294706#18294706 – Offbeatmammal Jul 03 '18 at 05:25
  • Offbeatmammal, thanks for the feedback. I can make it autoplay with a script video.play() at the background while it's hidden. My only concern now is to control the volume to 0. I can't seem to get it to work on Android but works fine on browser. – Shukri Damit Jul 03 '18 at 05:51

0 Answers0