Skip to main content
November 22, 2017
Answered

Switch between videos in real time

  • November 22, 2017
  • 1 reply
  • 415 views

Hello, I have 3 videos, from 3 different angles and I wanted to know how the user watching them can switch between angles in real time.

I want to make a looped version where you see 3 buttons (A,B,C) on the lower-left part of the screen, it starts at angle A and just keeps looping. When you press B you go to angle B, when you press C to angle C and so on. Thanks.

    This topic has been closed for replies.
    Correct answer Colin Holgate

    Oh yeah I forgot to tell you it was AS3, thank you so much for the answer! This is my first time working on something like this. I'll give it a try


    If it's just AS3 you can directly talk to the instances by name, which would make the code a bit shorter:

    showvid(va);

    stage.addEventListener(MouseEvent.CLICK,vidb);

    stop();

    function vidb(e:MouseEvent){

      showvid(vb);

    }

    function showvid(vidinstance:FLVPlayback){

      va.visible = false;

      va.play();

      vb.visible = false;

      vb.play();

      vc.visible = false;

      vc.play();

      vidinstance.visible = true;

    }

    1 reply

    Colin Holgate
    Inspiring
    November 22, 2017

    In what environment does this have to play back?

    November 22, 2017

    I wanted to make a simple flash file for a site. But I don't know exactly how to loop and mute them when you switch between angles so you don't hear 3 sounds at the same time.

    Colin Holgate
    Inspiring
    November 22, 2017

    I went ahead and assumed you were wanting HTML5! Here's what I came up with, but the general technique should work for AS3 as well:

    var video;

    showvid("va");

    stage.addEventListener("click",vidb);

    this.stop();

    function vidb(e){

      showvid("vb");

    }

    function showvid(vidname){

      video = document.getElementById("va");

      video.style.display = "none";

      video.play();

      video = document.getElementById("vb");

      video.style.display = "none";

      video.play();

      video = document.getElementById("vc");

      video.style.display = "none";

      video.play();

      video = document.getElementById(vidname);

      video.style.display = "block";

    }

    In my test I had a shape in the background, just to make the stage click work. It starts with playing a video that I gave an instance name of "va", then when I click it hides va, vb, and vc, and then shows vb.

    As for sound, are they due to have the same sound? If they do, just put the sound into one of the three, then you don't have to mute anything.

    For AS3 you could have three FLVPlayback components, and just set the visible of them to true or false.