Search code examples
flashactionscript-2relative-pathflvplayback

AS2: FLVPlayback component contentPath relativity


I have a site that loads in a XML file which tells where to find the assets to load into the main SWF. Images, and external SWFs load in correctly, but for some reason FLVs don't load at all unless the contentPath is an absolute path, which I can't have for this project. I've made my links relative to the HTML page as well.

My file structure is as such:

index.html -- The main loader file

project/shared/published/section1/loader.swf -- The main SWF to load

project/english/images/videos/welcome.flv -- The movie to load in.

Is it possible that the FLVPlayback contentPath's path is relative to the SWF and NOT the HTML page? Any help would be greatly appreciated.

Code for the page loading the video

import mx.video.*;

import mx.video.*;
playback1.contentPath = getNodeValue(findNode(videos, "one"));

// Assign the mySeekBar instance to the flvPlayback instance
playback1.playPauseButton = playpause;
playback1.backButton = myrewind;
playback1.seekBar = seekbar_container.myseek;
playback1.bufferingBar = mybuffer;

Solution

  • Hopefully this will help you. I created a test and this is what I have:

    Folder setup:

    flash/application/ - loader.swf and index.html

    flash/movies/ - movie.flv

    The path I used was - ../movies/movie.flv

    The code example is:

    /**
      Requires:
       - FLVPlayback component on the Stage with an instance name of my_FLVPlybk
    */
    import mx.video.*;
    my_FLVPlybk.contentPath = "../movies/movie.flv";
    var listenerObject:Object = new Object();
    listenerObject.metadataReceived = function(eventObject:Object):Void {
        my_FLVPlybk.setSize(my_FLVPlybk.preferredWidth, my_FLVPlybk.preferredHeight);
    }
    my_FLVPlybk.addEventListener("metadataReceived", listenerObject);
    

    I uploaded this to my localhost and it works fine.

    I have also tested it by moving the index outside the application folder to the flash folder and this shows that the FLV is indeed relative to the swf not the html.