function ClearAll(){ currentTrack = 0; currentCaption= undefined; currentSpeaker= -1; captionInfo = undefined; track.removeAll(); UpdateCaption(); } function StopNets(){ if (nets!=undefined){ nets.close(); delete nets; } if (id!=undefined){ clearInterval( id ); delete id; } } function GetTimeString(){ if (nets==undefined) return('--:--:--:---'); var t=nets.time*1000; var h=Math.floor(t/3600000);//hour t-=h*3600000; var m=Math.floor(t/60000);//minute t-=m*60000; var s=Math.floor(t/1000);//second t-=s*1000; t=Math.floor(t);//millisecond var q=h.toString(); while (q.length<2) q='0'+q; var f=q+':'; q=m.toString();; while (q.length<2) q='0'+q; f+=q+':'; q=s.toString(); while (q.length<2) q='0'+q; f+=q+':'; q=t.toString(); while (q.length<3) q='0'+q; f+=q; return(f); } function flvTimer() { dtTime = GetTimeString(); } ClearAll(); ply_btn.onPress = function (){ StopNets(); ClearAll(); liMarkers.removeAll(); taEvents.text=''; nc = new NetConnection(); nc.connect(null); nets = new NetStream(nc); nets.onCaptionInfo = function(obj){ taEvents.text=taEvents.text+GetTimeString()+' onCaptionInfo'+newline; ClearAll(); captionInfo=obj; arr=obj.tracks; for (n=1;n<=arr.length;n++){ track.addItem(arr[n-1].displayname,n-1); } } nets.onMarkerList = function(arr){ taEvents.text=taEvents.text+GetTimeString()+' onMarkerList'+newline; } nets.onCaption = function(captions,speaker){ currentCaption=captions; currentSpeaker=speaker; UpdateCaption(); } nets.onMarker = function(label){ liMarkers.addItem(GetTimeString()+' "'+label+'"'); liMarkers.selectedIndex = liMarkers.dataProvider.length-1; liMarkers.vPosition=9999999; } nets.onLastSecond = function(obj){ taEvents.text=taEvents.text+GetTimeString()+' onLastSecond'+newline; } nets.onMetaData = function(obj){ taEvents.text=taEvents.text+GetTimeString()+' onMetaData'+newline; } nets.onCuePoint = function(obj){ liMarkers.addItem(GetTimeString()+' "'+obj.name+'"'+' ('+obj.type+')'); liMarkers.selectedIndex = liMarkers.dataProvider.length-1; liMarkers.vPosition=9999999; } id = setInterval( flvTimer, 100 ); nets.SetBufferTime(10); video.attachVideo(nets); nets.play("ETFtrailer.flv"); } pause_btn.onPress = function(){ nets.pause(); } stop_btn.onPress = function(){ StopNets(); } bck_btn.onPress = function() { taCaptions.text=""; nets.seek( nets.time - 5 ); } fwd_btn.onPress = function (){ taCaptions.text=""; nets.seek( nets.time + 5 ); } function UpdateCaption(){ if (currentCaption==undefined) { taCaptions.text=""; } else { if (currentSpeaker==-1){ s=''; } else { s=''+captionInfo.speakers[currentSpeaker].name+': '; } taCaptions.text=s+currentCaption[currentTrack]; } } function change(evt){ currentTrack=evt.target.selectedItem.data; UpdateCaption(); } track.addEventListener("change", this);