topical media & game development

talk show tell print

flex-video-cue.mx

flex-video-cue.mx [swf] [flash] flex


  <?xml version="1.0" encoding="iso-8859-1"?>
  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp()" xmlns="*">
  <mx:Script>
   <![CDATA[
    import mx.events.CuePointEvent;
    import mx.controls.videoClasses.CuePointManager;
  
  

cur points


    
    private var ASCuePoints:Array = [{name:'ASCue0', time:2.60}, {name:'ASCue1', time:3.75}];
    private var cueArray:Array = new Array();
    private var index:int;
    
    private function initApp():void{ //Adding AS CuePoints
     myVD.cuePoints=ASCuePoints; 
     addCuePoints();
    }
    
    private function addCuePoints():void{ //Getting AS & MXML cuePoints
     for (var i:* in myVD.cuePoints){
      cueArray.push(myVD.cuePoints[i].time);
     }
     cueArray.sort(Array.NUMERIC);
    }
    
    private function addMetaCuePoints():void{// getting embedded cuePoints
     for (var i:* in myVD.metadata.cuePoints){
      cueArray.push(myVD.metadata.cuePoints[i].time);
     }
     cueArray.sort(Array.NUMERIC);
    }
    
    private function nextCue():void{ //Jump to next cue
     myVD.pause();
     if(index == cueArray.length-1){index=0}
     else {index++;}
     myVD.playheadTime = cueArray[index];
    }
    
  

get cue


    private function gotCue(event:CuePointEvent):void{ //Updating the index and traces
     index = cueArray.indexOf(event.cuePointTime);
     
     ta.text+= "Cue Point Namen : "+event.cuePointName+"\n";
     ta.text+= "Cue Point Time : "+event.cuePointTime+"\n";
     ta.text+= "----------------------------------------------\n";   
     
    }
   ]]>
  </mx:Script>
  <mx:VideoDisplay id="myVD" source="http://cetec77.com/kannan/assets/Candy.flv" metadataReceived="addMetaCuePoints()"
    cuePointManagerClass="mx.controls.videoClasses.CuePointManager"  cuePoint="gotCue(event)">
    <mx:cuePoints> <!-- MXML cuePoints -->
      <mx:Array>
       <mx:Object name="compileTimeCue0" time="1.00"/>
       <mx:Object name="compileTimeCue1" time="2.45"/>
     </mx:Array>
     </mx:cuePoints>
   </mx:VideoDisplay>
  

control


   <mx:HBox>
    <mx:Label text="playHeadTime : {myVD.playheadTime}"/>
   </mx:HBox>
   <mx:HBox >
    <mx:Button label="Play" click="myVD.play()"/>
    <mx:Button label="Pause" click="myVD.pause()"/>
    <mx:Button label="Stop" click="myVD.stop()"/>
    <mx:Button label="Jump to next Cue" click="nextCue()"/>
   </mx:HBox>
   <mx:TextArea id="ta" width="300" height="300"/>
    </mx:Application>
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.