Jump to content
Search Community

Adding cuepoints at runtime via a loop

metalG78 test
Moderator Tag

Recommended Posts

Hi there,

 

I'm trying to add cuepoints to a video at runtime to display subtitles. I'm using a loop to get my cuepoints from XML and add them using the addASCuePoint method. But for some reason only the first 2 cuepoints seem to be displaying.

 

Here is my for loop:

 

for (var i:int = 0; i < subtitlesXml.cuePoint.length(); i++)

   {

    cuepointStart = subtitlesXml.cuePoint.attribute("substart");

    cuepointEnd = subtitlesXml.cuePoint.attribute("subend");

    subtitles = subtitlesXml.cuePoint.subtitle;

      

    videoLoader.addASCuePoint(cuepointStart, "substart " + i, {id:i});   

    videoLoader.addASCuePoint(cuepointEnd, "subend");

   

    trace(cuepointStart + " " + cuepointEnd + " " + subtitles);

   }

 

and here is my cuepoint listener:

 

private function cuePointHandler(e:LoaderEvent):void

  {

   trace(e.data.name);

   if(e.data.name == "substart")

   {

    subTextField.text = subtitles[e.data.parameters.id];

   }  

   else if(e.data.name == "subend")

   {

    subTextField.text = "";

   }

   else if(e.data.name == "break")

   {

    fadeOutVideo();

   }

  }

 

And here is my XML:

 

<subtitles>

 

<cuePoint id="0" substart="7.0" subend="11.0">

  <subtitle><![CDATA[subtitle 1]></subtitle>

</cuePoint>

 

<cuePoint id="1" substart="16.0" subend="21.0">

  <subtitle><![CDATA[subtitle 2]]></subtitle>

</cuePoint>

 

<cuePoint id="2" substart="22:0" subend="24:0">

  <subtitle><![CDATA[subtitle 3]]></subtitle>

</cuePoint>

 

<cuePoint id="3" substart="26:0" subend="30:0">

  <subtitle><![CDATA[subtitle 4]]></subtitle>

</cuePoint>

 

<cuePoint id="4" substart="31:0" subend="35:0">

  <subtitle><![CDATA[subtitle 5]]></subtitle>

</cuePoint>

 

<cuePoint id="5" substart="36:0" subend="39:0">

  <subtitle><![CDATA[subtitle 6]]></subtitle>

</cuePoint>

 

Any help would be appreciated. 

 

Cheers

 

Gareth

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...