Flash MX 2004 Professional 13 Feb 2004 06:35 pm

Loading external media into the media components

I remember the first time that I tried using ActionScript to load an FLV into the MediaPlayback component - I could not find the method anywhere. Turns out the method is documented in the Media class, not the MediaPlayback component class. So if you’d like to load a file into a media component just use this code:

componentInstance.setMedia(pathToMediaFile:String, fileType:String);

Your only two options for “fileType” are “FLV” and “MP3.”

5 Responses to “Loading external media into the media components”

  1. on 13 Feb 2004 at 7:14 pm 1.Terry said …

    Also I would like to add:

    setMedia will fail if you don’t change the filepath between calls. for example, let’s say you have a training course that plays a video clip, after the clip is done, the user hits “next” then “back” the video will sometimes not get set by setMedia, and the video will not play.

    I solved this by making a dummy clip, and I use setMedia in my garbage collection routine to set the filepath to the dummy clip.

    I would also like to add, that it has been my experince the when you set the media, reguardless of whether “play automatically” is set in the componet inspector, the video will play the first half second of the clip at full volume, yes even if I set it componetInstance.volume = 0;

    Pardon the length of my comment : )
    p.s. on my wish list is an “unload media” method.

  2. on 15 Jun 2004 at 7:45 pm 2.bmack said …

    Wow, i love the way the flash just streams the flv files , what a difference in speed !!! But for some reason i cant seem to find any information, on making a second FLV file stream right after the first automatically. Does it have to be done with XML or can i just do it with action scripts ?

  3. on 23 Jul 2004 at 3:02 pm 3.Mike said …

    Yes, I’ve just been trying my hardest to get over that miserable bug with setMedia and it insisting on playing the first half second regardless of volume or autoPlay settings. Very, VERY annoying.
    I also would very much like to see an unload or even pauseLoad for the Media class.

  4. on 10 Aug 2004 at 3:37 pm 4.joanne strickland said …

    After an FLV plays, I have an action to load another swf into the same level. There is a delay of several seconds before the new swf tries to load. It is as if the swf with the FLV is holding on after its timeline finishes. Can I make this delay go away? Thanks. joanne

  5. on 19 Aug 2005 at 8:59 am 5.hardcore said …

    Wow, i love the way the flash just streams the flv files , what a difference in speed !!! But for some reason i cant seem to find any information, on making a second FLV file stream right after the first automatically. Does it have to be done with XML or can i just do it with action scripts ?

Subscribe to the comments through RSS Feed

Leave a Reply