Skip to main content
Known Participant
November 21, 2024
Question

whats the problem that the video does not stop when i click the button.

  • November 21, 2024
  • 2 replies
  • 14004 views

hi,

i would like to ask two questions.

i want a button on a video to pause the video.

i cant get it to work, not with the regular snippet nor with this code.

could anyone help me why this does not work.

 

...in the long run i want some buttons on the video that stop the running video and start a new one, a seperate one for every button.

 

i would be very thankful if someone could give me advice.

thanks a lot!

tomes

 

free video from here:  https://videos.pexels.com/video-files/2960875/2960875-hd_1920_1080_30fps.mp4

......btw. cant attach .fla files....any idea why ?

 

/* Mouse Click Event
Clicking on the specified symbol instance executes a function in which you can add your own custom code.

Instructions:
1. Add your custom code on a new line after the line that says "// Start your custom code" below.
The code will execute when the symbol instance is clicked.
*/

this.video01btn.addEventListener("click", fl_MouseClickHandler.bind(this));
function fl_MouseClickHandler()
{
// Start your custom code
// This example code displays the words "Mouse clicked" in the Output panel.
alert("Mouse clicked");
// End your custom code
}
/* Pause a Video
Use this code snippet to pause the selected video.
*/
{
$("#video01")[0].pause();
}

 

    2 replies

    kglad
    Community Expert
    Community Expert
    November 26, 2024

    and that's a mouse click listener to detect a click on omni and direct the use to the 21st (not 20th) frame.

    ROBGAUAuthor
    Known Participant
    November 26, 2024
    quote

    and that's a mouse click listener to detect a click on omni and direct the use to the 21st (not 20th) frame.


    By @kglad

    that i know, that part work perfect now since i learned that 1 is 0 and 20 is 19.......i wanted to know what code speech that is...i thought this is AS3 ?

    kglad
    Community Expert
    Community Expert
    November 26, 2024

    that's code for a html5/canvas project using the. createjs library and javascript.

    ROBGAUAuthor
    Known Participant
    November 22, 2024

    hi,

    cant get it to work. such an easy thing,  i have no idea why.

     

    this is the code that i have now. the button goes away after clicking, but the videos neither run, stop nor start...

    the object instance names are controlled and matching. the films are on the c drive and imported as component video

     

    any idea ? thanks for help !

    tomes

     

     

    canvas.style.zIndex = "1";

    // Instanzen zuweisen
    var video1 = this.film01; // Instanz des ersten Videos
    var video2 = this.film02; // Instanz des zweiten Videos
    var controlButton = this.controlButton; // Instanz des Buttons

    // Stelle sicher, dass Video 2 zu Beginn ausgeblendet ist
    video2.visible = false; // Video 2 wird anfangs nicht sichtbar sein

    // Event-Listener für den Button
    controlButton.addEventListener("click", function() {
    // Stopp das erste Video
    video1.stop();
    // Mache Video 1 unsichtbar
    video1.visible = false;

    // Mache Video 2 sichtbar
    video2.visible = true;
    // Starte Video 2
    video2.play();

    // Optional: Button ausblenden oder eine andere Funktion ausführen
    controlButton.visible = false; // Verstecke den Button nach dem Klick
    });

     

     

    ROBGAUAuthor
    Known Participant
    November 22, 2024

    so it seems  i come a little bit nearer...tough work...

     

    so film01 runs, button click shows for a half secont the film02 but then directly shows film01 again.

    i tried to end film01 after clicking the button in the script in frame 1 and the same scripting in frame 15 for film 02, but that does not work. ....do i have to maybe reset the "buttonclick" in frame 15 in any way?

    any better idea?

     

    thanks

    kglad
    Community Expert
    Community Expert
    November 22, 2024

    does the developer console show any errors?