Tag Archives: flex

import flash.media.Sound;

import org.osmf.events.MediaPlayerStateChangeEvent;
import org.osmf.events.TimeEvent;
import org.osmf.events.PlayEvent;
import org.osmf.events.SeekEvent;

[Embed (source=”/html/data/a24x1x1.mp3″ )]
private var bounce_01:Class;
private var bounce_01_mp3:Sound = new bounce_01();
private var _soundChannel:SoundChannel;
private var _currentSndPosition:Number;
private var isPlayingSound:Boolean;

public function playSound():void {
isPlayingSound = true;
trace(“play Sound”);
_soundChannel = bounce_01_mp3.play();
_soundChannel.stop();

}

//myVideoPlayer.addEventListener(MediaPlayerStateChangeEvent.MEDIA_PLAYER_STATE_CHANGE, vpMediaPlayerStateChangeHandler);
//myVideoPlayer.addEventListener(TimeEvent.CURRENT_TIME_CHANGE, vpMediaPlayerSeekChangeHandler);

protected function vpMediaPlayerStateChangeHandler(event:MediaPlayerStateChangeEvent):void {
trace(event.state);
if(event.state == “paused”) {
if (isPlayingSound == true) {
_currentSndPosition = _soundChannel.position;
trace(_currentSndPosition);
_soundChannel.stop();}
}
else if (event.state ==”playing”) {
if (isPlayingSound == true) {
_soundChannel.stop();
_soundChannel = bounce_01_mp3.play(_currentSndPosition);
}
}
}

protected function vpMediaPlayerSeekChangeHandler(event:TimeEvent):void {
_currentSndPosition = event.time * 60;
trace(“TIME”);
trace(event.time);
}

Advertisements