How to autoplay a video from a specific time and once the video is done replaying it will start it from the begining

Comments

3 comments

  • Avatar
    Michal Kuperman

    Hi Itamar,

    Thanks for contacting us.

    You can remove the `autoplay` attribute like this:

    player.on('ended', (event) => {
    player.videoElement.removeAttribute('autoplay')
    player.source('sample', {})
    })

    Let us know if this works for you.

    Regards,
    Michal

    0
    Comment actions Permalink
  • Avatar
    Itamar Golan

    Hey Michal,
    Thank you for your comment.

    Unfortunately the code you provided does not work for me.

    "player.videoElement" return 'undefined' and thus I'm getting the following error:

    VIDEOJS: ERROR: TypeError: Cannot read properties of undefined (reading 'removeAttribute')

    0
    Comment actions Permalink
  • Avatar
    Michal Kuperman

    Hi Itamar,

    I'm attaching the full code:

    HTML:

    <html>
    <head>
    <link href="https://unpkg.com/cloudinary-video-player@1.5.9/dist/cld-video-player.min.css" rel="stylesheet">
    <script src="https://unpkg.com/cloudinary-core@latest/cloudinary-core-shrinkwrap.min.js" type="text/javascript"></script>
    <script src="https://unpkg.com/cloudinary-video-player@1.5.9/dist/cld-video-player.min.js"
    type="text/javascript"></script>
    </head>
    <body>
    <video id="player" controls autoplay class="cld-video-player cld-video-player-skin-dark">
    </video>
    </body>
    </html>

    JS:

    var source ="https://res.cloudinary.com/demo/video/upload/dog.mp4"

    var cld = cloudinary.Cloudinary.new({
    cloud_name: "myCloud"
    });
    const player = cld.videoPlayer('player', {
    });

    player.source(source, {})

    player.on('ended', (event) => {
    player.videoElement.removeAttribute('autoplay')
    player.source('elephants', {})
    })

    In order to further assist, can you please provide your code?

    Looking forward to your updates

    0
    Comment actions Permalink

Please sign in to leave a comment.