[flex] flex播放器第一次播放时,进度条显示的总时间为59:59

空谷悠悠 2010-08-04
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" horizontalAlign="center" verticalAlign="top" fontSize="12">
	<mx:Script>
		<![CDATA[
			private var currentTime:Date;
			private var totalTime:Date;
			
			private function getTime():void
			{
               currentTime = new Date(myPlayer.playheadTime*1000||10);
               totalTime = new Date(myPlayer.totalTime*1000);
               progressBar.label = dateFormatter.format(currentTime)+"/"+dateFormatter.format(totalTime);
			}
		]]>
	</mx:Script>
	<mx:DateFormatter id="dateFormatter" formatString="NN:SS" />
	<mx:Panel width="520" height="400" title="Flex播放器">
		<mx:VideoDisplay id="myPlayer" autoPlay="false" width="100%" height="100%" playheadUpdate="getTime();" 
				source="assets/mymtv.flv" volume="{volSlider.value}" />		
		<mx:HBox paddingBottom="5" paddingLeft="5" width="100%">		
			<mx:Image source="@Embed('assets/play.png')" click="myPlayer.play();" />
			<mx:Image source="@Embed('assets/pause.png')" click="myPlayer.pause();" />			
			<mx:Image source="@Embed('assets/stop.png')" click="myPlayer.stop();" />		
			<mx:ProgressBar id="progressBar" source="myPlayer" labelPlacement="center" width="300" />
			<mx:Label text="Vol" />
			<mx:HSlider id="volSlider" width="50" minimum="0" value="0.5" maximum="1" snapInterval="0.1" />				
		</mx:HBox>
	</mx:Panel>	
</mx:Application>

 flex播放器第一次播放时,进度条显示的总时间为59:59,当第一次播放完,再一次播放时,进度条显示的总时间才正确。求怎么样才能让第一次就显示正确?

javaEEdevelop 2011-04-19
在VideoDisplay 的
MetadataEvent.METADATA_RECEIVED事件 或VideoEvent.READY事件中来获取总时间
Global site tag (gtag.js) - Google Analytics