video.Maru
by polyGeek polyGeek logo



 

Using ExternalInterface to change videos with video.Maru

November 15th, 2007 . by polyGeek

Would you like to play Flash videos on your site and have links to play various different videos in your HTML code?

Here’s how to do it using the Flash player’s External Interface as a bridge between Javascript and Actionscript, which then uses the video.Maru API to switch videos.


Download source here, 1.2 megs with videos.

Delivery
Sky
Cossacks

Here’s what the Actionscript code looks like:

Take a look at the first line of code: System.security.allowDomain(’http://videomaru.com/’). You’ll have to edit that to make it work on your machine. And give the System.security docs a read if you have any problems. I got everything to work by just opening the .htm file locally but that’s not always the case. Sometimes the ExternalInterface doesn’t work unless you are using a hosted file. I’ve wasted many an hour trying to debug when forgetting that little nugget. :-)

And this is all there is to the Javascript:

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Technorati
  • del.icio.us
  • Facebook
  • Google
  • StumbleUpon

8 Responses to “Using ExternalInterface to change videos with video.Maru”

  1. comment number 1 by: Matt

    Can the fullscreen option work with The ExternalInterface option?

    What I would really like to do is have a page with various links in it that causes a pop up window that shows the proper video depending on what link they click on. Is there anywhere I can get information on doing that.

    Thanks,

    Matt

  2. comment number 2 by: polyGeek

    @Matt, what you probably want to do is use FlashVars for that. Your links would just open a unique popup window as usual. Each popup window would load the same SWF/videoPlayer. In the / tag you would add an attribute for FlashVars that would be the link to the specific video you want to play in that popup.

    Does that work for you?

  3. comment number 3 by: Matt

    Thank You… I hope this works… one more question.

    The menu on fullscreen mode can you get it so that it does not expand with the screen.

    Thanks

    Matt

  4. comment number 4 by: polyGeek

    @Matt, I’ll look into what you can and cannot do with Fullscreen and write a tutorial about it. My understanding is that Fullscreen just scales everything up. But there might be some API calls that I could add that would scale things back again. We’ll see.

  5. comment number 5 by: Richard

    Hi Dan,

    I’ve worked with this and it works great. There is however a small issue:

    If you pause or stop a video that is currently playing and then click a link to load another video, the play/pause toogle isn’t reset.

    I’ve tried playing with the AS and got it a little better:

    function playVideo( s:String ):Void {
    videoMaru.playVideo( s );
    play_btn.gotoAndStop(”paused”)
    }

    but I don’t know how to really address your MovieClips (pause/play)?

    Thanks

  6. comment number 6 by: Richard

    Sorry Dan,

    I think I’ve just sussed this? Adding this seemed to work:

    function playVideo( s:String ):Void {
    videoMaru.playVideo( s );
    videoMaru.setIsPlaying(true);
    }

  7. comment number 7 by: polyGeek

    @Richard, I think this has all been fixed in video.Maru 3.5 beta. Could you download it and see if it works with your setup?

  8. comment number 8 by: Anthony

    Note that if you want to play an RTMP stream you’ll need to use:
    videoMaru.playRTMP( s );
    instead of
    videoMaru.playVideo( s );
    At least I had to.

    Cheers

Leave a Reply

Name

Mail (never published)

Website