autoplay on video not working

autoplay on video not working

by Ben Smith -
Number of replies: 1

Using Moodle 3.4.1+ (Build: 20180208), PHP 7.2.2 with Zend Engine v3.2.0, mySQL  Ver 14.14, on Ubuntu 16.04.3 LTS, fresh install with Essential theme and default videojs media player.  Everything running swimmingly, but when I try to embed a 6 second mp4 d25ixnv6uinqzi.cloudfront.net/year4/uotw80.1.mp4 into a quiz question that I would like to autoplay and loop, it doesn't autoplay.  No log error messages, even with debugging on.  When I go back to edit the question, the option to autoplay is unchecked.  If I got to the code editor and add autoplay="autoplay" same result.  It looks like videojs is stripping my manual attributes from the video tag.  

On a more code-centric note, I tried to pragmatically play the file after page load, but I don't have access to the videojs function for some reason, I get a 'undefined function' in the chrome dev panel.  I think I don't know enough about requirejs to fix this problem.


Any ideas?

Ben


Average of ratings: -
In reply to Ben Smith

Re: autoplay on video not working

by Ben Smith -

Update:  I've figured out how to start the player using jquery after it is (apparently) auto-paused.  Here's the code:

$( document ).ready(function() {
       $("video").on("pause", function (e) {
              console.log("Video paused. Current time of videoplay: " + e.target.currentTime );
              e.target.play();
          });
});

When the quiz question with the embedded video loads, the video flickers and then starts.  In the console I get  "Video paused. Current time of videoplay: 0.192707".  Why is videojs pausing the video?