mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-21 01:37:50 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,41 @@
|
||||
package org.osmf.elements.audioClasses
|
||||
{
|
||||
import flash.media.SoundTransform;
|
||||
import org.osmf.traits.AudioTrait;
|
||||
|
||||
public class AudioAudioTrait extends AudioTrait
|
||||
{
|
||||
|
||||
private var soundAdapter:SoundAdapter;
|
||||
|
||||
public function AudioAudioTrait(param1:SoundAdapter)
|
||||
{
|
||||
super();
|
||||
this.soundAdapter = param1;
|
||||
param1.soundTransform.volume = volume;
|
||||
param1.soundTransform.pan = pan;
|
||||
}
|
||||
|
||||
override protected function volumeChangeStart(param1:Number) : void
|
||||
{
|
||||
var _loc2_:SoundTransform = this.soundAdapter.soundTransform;
|
||||
_loc2_.volume = muted ? 0 : param1;
|
||||
this.soundAdapter.soundTransform = _loc2_;
|
||||
}
|
||||
|
||||
override protected function mutedChangeStart(param1:Boolean) : void
|
||||
{
|
||||
var _loc2_:SoundTransform = this.soundAdapter.soundTransform;
|
||||
_loc2_.volume = param1 ? 0 : volume;
|
||||
this.soundAdapter.soundTransform = _loc2_;
|
||||
}
|
||||
|
||||
override protected function panChangeStart(param1:Number) : void
|
||||
{
|
||||
var _loc2_:SoundTransform = this.soundAdapter.soundTransform;
|
||||
_loc2_.pan = param1;
|
||||
this.soundAdapter.soundTransform = _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package org.osmf.elements.audioClasses
|
||||
{
|
||||
import flash.events.Event;
|
||||
import org.osmf.traits.PlayState;
|
||||
import org.osmf.traits.PlayTrait;
|
||||
|
||||
public class AudioPlayTrait extends PlayTrait
|
||||
{
|
||||
|
||||
private var lastPlayFailed:Boolean = false;
|
||||
|
||||
private var soundAdapter:SoundAdapter;
|
||||
|
||||
public function AudioPlayTrait(param1:SoundAdapter)
|
||||
{
|
||||
super();
|
||||
this.soundAdapter = param1;
|
||||
param1.addEventListener(Event.COMPLETE,this.onPlaybackComplete,false,1,true);
|
||||
}
|
||||
|
||||
override protected function playStateChangeStart(param1:String) : void
|
||||
{
|
||||
if(param1 == PlayState.PLAYING)
|
||||
{
|
||||
this.lastPlayFailed = !this.soundAdapter.play();
|
||||
}
|
||||
else if(param1 == PlayState.PAUSED)
|
||||
{
|
||||
this.soundAdapter.pause();
|
||||
}
|
||||
else if(param1 == PlayState.STOPPED)
|
||||
{
|
||||
this.soundAdapter.stop();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function playStateChangeEnd() : void
|
||||
{
|
||||
if(this.lastPlayFailed)
|
||||
{
|
||||
stop();
|
||||
this.lastPlayFailed = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
super.playStateChangeEnd();
|
||||
}
|
||||
}
|
||||
|
||||
private function onPlaybackComplete(param1:Event) : void
|
||||
{
|
||||
stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.osmf.elements.audioClasses
|
||||
{
|
||||
import org.osmf.traits.SeekTrait;
|
||||
import org.osmf.traits.TimeTrait;
|
||||
|
||||
public class AudioSeekTrait extends SeekTrait
|
||||
{
|
||||
|
||||
private var soundAdapter:SoundAdapter;
|
||||
|
||||
public function AudioSeekTrait(param1:TimeTrait, param2:SoundAdapter)
|
||||
{
|
||||
super(param1);
|
||||
this.soundAdapter = param2;
|
||||
}
|
||||
|
||||
override protected function seekingChangeStart(param1:Boolean, param2:Number) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
this.soundAdapter.seek(param2);
|
||||
}
|
||||
}
|
||||
|
||||
override protected function seekingChangeEnd(param1:Number) : void
|
||||
{
|
||||
super.seekingChangeEnd(param1);
|
||||
if(seeking == true)
|
||||
{
|
||||
setSeeking(false,param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.osmf.elements.audioClasses
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.events.ProgressEvent;
|
||||
import org.osmf.traits.TimeTrait;
|
||||
|
||||
public class AudioTimeTrait extends TimeTrait
|
||||
{
|
||||
|
||||
private var soundAdapter:SoundAdapter;
|
||||
|
||||
public function AudioTimeTrait(param1:SoundAdapter)
|
||||
{
|
||||
super();
|
||||
this.soundAdapter = param1;
|
||||
param1.addEventListener(ProgressEvent.PROGRESS,this.onDownloadProgress,false,0,true);
|
||||
param1.addEventListener(SoundAdapter.DOWNLOAD_COMPLETE,this.onDownloadComplete,false,0,true);
|
||||
param1.addEventListener(Event.COMPLETE,this.onPlaybackComplete,false,0,true);
|
||||
}
|
||||
|
||||
override public function get currentTime() : Number
|
||||
{
|
||||
return this.soundAdapter.currentTime;
|
||||
}
|
||||
|
||||
private function onDownloadProgress(param1:Event) : void
|
||||
{
|
||||
if(!isNaN(this.soundAdapter.estimatedDuration) && this.soundAdapter.estimatedDuration > 0)
|
||||
{
|
||||
this.soundAdapter.removeEventListener(ProgressEvent.PROGRESS,this.onDownloadProgress);
|
||||
setDuration(this.soundAdapter.estimatedDuration);
|
||||
}
|
||||
}
|
||||
|
||||
private function onDownloadComplete(param1:Event) : void
|
||||
{
|
||||
setDuration(this.soundAdapter.estimatedDuration);
|
||||
}
|
||||
|
||||
private function onPlaybackComplete(param1:Event) : void
|
||||
{
|
||||
signalComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
package org.osmf.elements.audioClasses
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.events.ProgressEvent;
|
||||
import flash.media.Sound;
|
||||
import flash.media.SoundChannel;
|
||||
import flash.media.SoundTransform;
|
||||
import org.osmf.events.MediaError;
|
||||
import org.osmf.events.MediaErrorCodes;
|
||||
import org.osmf.events.MediaErrorEvent;
|
||||
import org.osmf.media.MediaElement;
|
||||
|
||||
public class SoundAdapter extends EventDispatcher
|
||||
{
|
||||
|
||||
public static const DOWNLOAD_COMPLETE:String = "downloadComplete";
|
||||
|
||||
private var owner:MediaElement;
|
||||
|
||||
private var _soundTransform:SoundTransform;
|
||||
|
||||
private var sound:Sound;
|
||||
|
||||
private var playing:Boolean = false;
|
||||
|
||||
private var channel:SoundChannel;
|
||||
|
||||
private var lastStartTime:Number = 0;
|
||||
|
||||
public function SoundAdapter(param1:MediaElement, param2:Sound)
|
||||
{
|
||||
super();
|
||||
this.owner = param1;
|
||||
this.sound = param2;
|
||||
this._soundTransform = new SoundTransform();
|
||||
param2.addEventListener(Event.COMPLETE,this.onDownloadComplete,false,0,true);
|
||||
param2.addEventListener(ProgressEvent.PROGRESS,this.onProgress,false,0,true);
|
||||
param2.addEventListener(IOErrorEvent.IO_ERROR,this.onIOError,false,0,true);
|
||||
}
|
||||
|
||||
public function get currentTime() : Number
|
||||
{
|
||||
return this.channel != null ? this.channel.position / 1000 : this.lastStartTime / 1000;
|
||||
}
|
||||
|
||||
public function get estimatedDuration() : Number
|
||||
{
|
||||
return this.sound.length / (1000 * this.sound.bytesLoaded / this.sound.bytesTotal);
|
||||
}
|
||||
|
||||
public function get soundTransform() : SoundTransform
|
||||
{
|
||||
return this._soundTransform;
|
||||
}
|
||||
|
||||
public function set soundTransform(param1:SoundTransform) : void
|
||||
{
|
||||
this._soundTransform = param1;
|
||||
if(this.channel != null)
|
||||
{
|
||||
this.channel.soundTransform = param1;
|
||||
}
|
||||
}
|
||||
|
||||
public function play(param1:Number = -1) : Boolean
|
||||
{
|
||||
var time:Number = param1;
|
||||
var success:Boolean = false;
|
||||
if(this.channel == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.channel = this.sound.play(time != -1 ? time : this.lastStartTime);
|
||||
}
|
||||
catch(error:ArgumentError)
|
||||
{
|
||||
channel = null;
|
||||
}
|
||||
if(this.channel != null)
|
||||
{
|
||||
this.playing = true;
|
||||
this.channel.soundTransform = this._soundTransform;
|
||||
this.channel.addEventListener(Event.SOUND_COMPLETE,this.onSoundComplete);
|
||||
success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.owner.dispatchEvent(new MediaErrorEvent(MediaErrorEvent.MEDIA_ERROR,false,false,new MediaError(MediaErrorCodes.SOUND_PLAY_FAILED)));
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
public function pause() : void
|
||||
{
|
||||
if(this.channel != null)
|
||||
{
|
||||
this.lastStartTime = this.channel.position;
|
||||
this.clearChannel();
|
||||
this.playing = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function stop() : void
|
||||
{
|
||||
if(this.channel != null)
|
||||
{
|
||||
this.lastStartTime = 0;
|
||||
this.clearChannel();
|
||||
this.playing = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function seek(param1:Number) : void
|
||||
{
|
||||
var _loc2_:Boolean = this.playing;
|
||||
if(this.channel != null)
|
||||
{
|
||||
this.clearChannel();
|
||||
}
|
||||
this.play(param1 * 1000);
|
||||
if(_loc2_ == false)
|
||||
{
|
||||
this.pause();
|
||||
}
|
||||
}
|
||||
|
||||
private function clearChannel() : void
|
||||
{
|
||||
if(this.channel != null)
|
||||
{
|
||||
this.channel.removeEventListener(Event.SOUND_COMPLETE,this.onSoundComplete);
|
||||
this.channel.stop();
|
||||
this.channel = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function onSoundComplete(param1:Event) : void
|
||||
{
|
||||
this.lastStartTime = this.channel.position;
|
||||
this.clearChannel();
|
||||
this.playing = false;
|
||||
dispatchEvent(new Event(Event.COMPLETE));
|
||||
}
|
||||
|
||||
private function onDownloadComplete(param1:Event) : void
|
||||
{
|
||||
dispatchEvent(new Event(DOWNLOAD_COMPLETE));
|
||||
}
|
||||
|
||||
private function onProgress(param1:ProgressEvent) : void
|
||||
{
|
||||
dispatchEvent(param1.clone());
|
||||
}
|
||||
|
||||
private function onIOError(param1:IOErrorEvent) : void
|
||||
{
|
||||
this.owner.dispatchEvent(new MediaErrorEvent(MediaErrorEvent.MEDIA_ERROR,false,false,new MediaError(MediaErrorCodes.IO_ERROR)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package org.osmf.elements.audioClasses
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.events.ProgressEvent;
|
||||
import flash.media.Sound;
|
||||
import org.osmf.events.LoadEvent;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
import org.osmf.traits.LoadState;
|
||||
import org.osmf.traits.LoadTrait;
|
||||
import org.osmf.traits.LoaderBase;
|
||||
|
||||
public class SoundLoadTrait extends LoadTrait
|
||||
{
|
||||
|
||||
private var lastBytesTotal:Number;
|
||||
|
||||
private var _sound:Sound;
|
||||
|
||||
public function SoundLoadTrait(param1:LoaderBase, param2:MediaResourceBase)
|
||||
{
|
||||
super(param1,param2);
|
||||
}
|
||||
|
||||
public function get sound() : Sound
|
||||
{
|
||||
return this._sound;
|
||||
}
|
||||
|
||||
public function set sound(param1:Sound) : void
|
||||
{
|
||||
this._sound = param1;
|
||||
}
|
||||
|
||||
override protected function loadStateChangeStart(param1:String) : void
|
||||
{
|
||||
if(param1 == LoadState.READY)
|
||||
{
|
||||
if(this._sound != null)
|
||||
{
|
||||
this._sound.addEventListener(Event.OPEN,this.bytesTotalCheckingHandler,false,0,true);
|
||||
this._sound.addEventListener(ProgressEvent.PROGRESS,this.bytesTotalCheckingHandler,false,0,true);
|
||||
}
|
||||
}
|
||||
else if(param1 == LoadState.UNINITIALIZED)
|
||||
{
|
||||
this._sound = null;
|
||||
}
|
||||
}
|
||||
|
||||
override public function get bytesLoaded() : Number
|
||||
{
|
||||
return this._sound ? this._sound.bytesLoaded : NaN;
|
||||
}
|
||||
|
||||
override public function get bytesTotal() : Number
|
||||
{
|
||||
return this._sound ? this._sound.bytesTotal : NaN;
|
||||
}
|
||||
|
||||
private function bytesTotalCheckingHandler(param1:Event) : void
|
||||
{
|
||||
var _loc2_:LoadEvent = null;
|
||||
if(this.lastBytesTotal != this._sound.bytesTotal)
|
||||
{
|
||||
_loc2_ = new LoadEvent(LoadEvent.BYTES_TOTAL_CHANGE,false,false,null,this._sound.bytesTotal);
|
||||
this.lastBytesTotal = this._sound.bytesTotal;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user