• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

HTML5 canvas - Mpeg play/pause button

Community Beginner ,
Aug 25, 2018 Aug 25, 2018

Copy link to clipboard

Copied

Hi everyone,

I've inserted a video component in my HTML5 canvas.

Now, I want to automatically pause the video before it ends.

Moreover I'd like to add a button in order to make it play from that point onwards.

Unfortunately actions like this.play() and this.stop() do not work.

There should be some tricky code that allows to control the video player.

How is this possible?

Thank you in advance

Views

432

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Aug 25, 2018 Aug 25, 2018

Sorry, there's no tricky code, just very simple code:

document.getElementById("myvideo").pause();

document.getElementById("myvideo").play();

HTMLMediaElement - Web APIs | MDN

Votes

Translate

Translate
LEGEND ,
Aug 25, 2018 Aug 25, 2018

Copy link to clipboard

Copied

Sorry, there's no tricky code, just very simple code:

document.getElementById("myvideo").pause();

document.getElementById("myvideo").play();

HTMLMediaElement - Web APIs | MDN

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 08, 2021 Nov 08, 2021

Copy link to clipboard

Copied

LATEST

hi

I tested this using a button called 'stopvideo' created in my HTML file that does works perfectly:

$("#stopvideo").click(function(){
document.getElementById("JimVideo").pause();
});
 
I have used this external Javascript in my HTML document which also works :
var aud = document.getElementById('JimVideo');
var approxTime = 0
aud.ontimeupdate = function(){
    var currentTime = Math.floor(aud.currentTime);
    if (currentTime !== approxTime) {
        approxTime = currentTime;
        if (approxTime === 4) {
document.getElementById("JimVideo").pause();
        }
    }
};
 
However I am at a loss on how to implement the 'get currentTime function' in order to automatically have the video stop (say after 4 seconds) BUT from within the Adobe animate canvas say on the initial keyframe where the video component exist. Any suggestions on how to figure this out. Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines