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
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: