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

html5 video player button

Explorer ,
Oct 06, 2020 Oct 06, 2020

with the video component control disable and having a single custom button to control the play and pause of the video.

 

what should be the exact format of the code or script for it. 

 

//===========

var _this = this;

_this.button_play.on('click', function () {
$('#videoplayer')[0].play();
});

//===========

368
Translate
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

Community Expert , Oct 07, 2020 Oct 07, 2020

sure:

 

this.toggle_mc.addEventListener("click",toggleF);


function toggleF(){

if($('#v1')[0].paused){
$('#v1')[0].play();

} else {

$('#v1')[0].pause();

}
}

Translate
Community Expert ,
Oct 06, 2020 Oct 06, 2020

that should work.  use pause() to stop the video.

 

my personal preference (for no good reason) is to use the more verbose:

 

this.stop_mc.addEventListener("click",stopF);
this.play_mc.addEventListener("click",playF);


function playF(){
$('#v1')[0].play();
}


function stopF(){
$('#v1')[0].pause();
}

Translate
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
Explorer ,
Oct 06, 2020 Oct 06, 2020

is there a way we can use single button to control the play and pause?

Translate
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
Community Expert ,
Oct 07, 2020 Oct 07, 2020

sure:

 

this.toggle_mc.addEventListener("click",toggleF);


function toggleF(){

if($('#v1')[0].paused){
$('#v1')[0].play();

} else {

$('#v1')[0].pause();

}
}

Translate
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
Explorer ,
Oct 07, 2020 Oct 07, 2020

yes this is working for my need.

 

Thank you @kglad 

Translate
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
Community Expert ,
Oct 08, 2020 Oct 08, 2020
LATEST

you're welcome.

Translate
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