mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 17: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 = soundAdapter.soundTransform;
|
||||
_loc2_.volume = muted ? 0 : param1;
|
||||
soundAdapter.soundTransform = _loc2_;
|
||||
}
|
||||
|
||||
override protected function mutedChangeStart(param1:Boolean) : void
|
||||
{
|
||||
var _loc2_:SoundTransform = soundAdapter.soundTransform;
|
||||
_loc2_.volume = param1 ? 0 : volume;
|
||||
soundAdapter.soundTransform = _loc2_;
|
||||
}
|
||||
|
||||
override protected function panChangeStart(param1:Number) : void
|
||||
{
|
||||
var _loc2_:SoundTransform = soundAdapter.soundTransform;
|
||||
_loc2_.pan = param1;
|
||||
soundAdapter.soundTransform = _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package org.osmf.elements.audioClasses
|
||||
{
|
||||
import flash.events.Event;
|
||||
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("complete",onPlaybackComplete,false,1,true);
|
||||
}
|
||||
|
||||
override protected function playStateChangeStart(param1:String) : void
|
||||
{
|
||||
if(param1 == "playing")
|
||||
{
|
||||
lastPlayFailed = !soundAdapter.play();
|
||||
}
|
||||
else if(param1 == "paused")
|
||||
{
|
||||
soundAdapter.pause();
|
||||
}
|
||||
else if(param1 == "stopped")
|
||||
{
|
||||
soundAdapter.stop();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function playStateChangeEnd() : void
|
||||
{
|
||||
if(lastPlayFailed)
|
||||
{
|
||||
stop();
|
||||
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)
|
||||
{
|
||||
soundAdapter.seek(param2);
|
||||
}
|
||||
}
|
||||
|
||||
override protected function seekingChangeEnd(param1:Number) : void
|
||||
{
|
||||
super.seekingChangeEnd(param1);
|
||||
if(seeking == true)
|
||||
{
|
||||
setSeeking(false,param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.osmf.elements.audioClasses
|
||||
{
|
||||
import flash.events.Event;
|
||||
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("progress",onDownloadProgress,false,0,true);
|
||||
param1.addEventListener("downloadComplete",onDownloadComplete,false,0,true);
|
||||
param1.addEventListener("complete",onPlaybackComplete,false,0,true);
|
||||
}
|
||||
|
||||
override public function get currentTime() : Number
|
||||
{
|
||||
return soundAdapter.currentTime;
|
||||
}
|
||||
|
||||
private function onDownloadProgress(param1:Event) : void
|
||||
{
|
||||
if(!isNaN(soundAdapter.estimatedDuration) && soundAdapter.estimatedDuration > 0)
|
||||
{
|
||||
soundAdapter.removeEventListener("progress",onDownloadProgress);
|
||||
setDuration(soundAdapter.estimatedDuration);
|
||||
}
|
||||
}
|
||||
|
||||
private function onDownloadComplete(param1:Event) : void
|
||||
{
|
||||
setDuration(soundAdapter.estimatedDuration);
|
||||
}
|
||||
|
||||
private function onPlaybackComplete(param1:Event) : void
|
||||
{
|
||||
signalComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
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.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;
|
||||
_soundTransform = new SoundTransform();
|
||||
param2.addEventListener("complete",onDownloadComplete,false,0,true);
|
||||
param2.addEventListener("progress",onProgress,false,0,true);
|
||||
param2.addEventListener("ioError",onIOError,false,0,true);
|
||||
}
|
||||
|
||||
public function get currentTime() : Number
|
||||
{
|
||||
return channel != null ? channel.position / 1000 : lastStartTime / 1000;
|
||||
}
|
||||
|
||||
public function get estimatedDuration() : Number
|
||||
{
|
||||
return sound.length / (1000 * sound.bytesLoaded / sound.bytesTotal);
|
||||
}
|
||||
|
||||
public function get soundTransform() : SoundTransform
|
||||
{
|
||||
return _soundTransform;
|
||||
}
|
||||
|
||||
public function set soundTransform(param1:SoundTransform) : void
|
||||
{
|
||||
_soundTransform = param1;
|
||||
if(channel != null)
|
||||
{
|
||||
channel.soundTransform = param1;
|
||||
}
|
||||
}
|
||||
|
||||
public function play(param1:Number = -1) : Boolean
|
||||
{
|
||||
var _loc2_:Boolean = false;
|
||||
if(channel == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
channel = sound.play(param1 != -1 ? param1 : lastStartTime);
|
||||
}
|
||||
catch(error:ArgumentError)
|
||||
{
|
||||
channel = null;
|
||||
}
|
||||
if(channel != null)
|
||||
{
|
||||
playing = true;
|
||||
channel.soundTransform = _soundTransform;
|
||||
channel.addEventListener("soundComplete",onSoundComplete);
|
||||
_loc2_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
owner.dispatchEvent(new MediaErrorEvent("mediaError",false,false,new MediaError(10)));
|
||||
}
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function pause() : void
|
||||
{
|
||||
if(channel != null)
|
||||
{
|
||||
lastStartTime = channel.position;
|
||||
clearChannel();
|
||||
playing = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function stop() : void
|
||||
{
|
||||
if(channel != null)
|
||||
{
|
||||
lastStartTime = 0;
|
||||
clearChannel();
|
||||
playing = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function seek(param1:Number) : void
|
||||
{
|
||||
var _loc2_:Boolean = playing;
|
||||
if(channel != null)
|
||||
{
|
||||
clearChannel();
|
||||
}
|
||||
play(param1 * 1000);
|
||||
if(_loc2_ == false)
|
||||
{
|
||||
pause();
|
||||
}
|
||||
}
|
||||
|
||||
private function clearChannel() : void
|
||||
{
|
||||
if(channel != null)
|
||||
{
|
||||
channel.removeEventListener("soundComplete",onSoundComplete);
|
||||
channel.stop();
|
||||
channel = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function onSoundComplete(param1:Event) : void
|
||||
{
|
||||
lastStartTime = channel.position;
|
||||
clearChannel();
|
||||
playing = false;
|
||||
dispatchEvent(new Event("complete"));
|
||||
}
|
||||
|
||||
private function onDownloadComplete(param1:Event) : void
|
||||
{
|
||||
dispatchEvent(new Event("downloadComplete"));
|
||||
}
|
||||
|
||||
private function onProgress(param1:ProgressEvent) : void
|
||||
{
|
||||
dispatchEvent(param1.clone());
|
||||
}
|
||||
|
||||
private function onIOError(param1:IOErrorEvent) : void
|
||||
{
|
||||
owner.dispatchEvent(new MediaErrorEvent("mediaError",false,false,new MediaError(1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package org.osmf.elements.audioClasses
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.media.Sound;
|
||||
import org.osmf.events.LoadEvent;
|
||||
import org.osmf.media.MediaResourceBase;
|
||||
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 _sound;
|
||||
}
|
||||
|
||||
public function set sound(param1:Sound) : void
|
||||
{
|
||||
_sound = param1;
|
||||
}
|
||||
|
||||
override protected function loadStateChangeStart(param1:String) : void
|
||||
{
|
||||
if(param1 == "ready")
|
||||
{
|
||||
if(_sound != null)
|
||||
{
|
||||
_sound.addEventListener("open",bytesTotalCheckingHandler,false,0,true);
|
||||
_sound.addEventListener("progress",bytesTotalCheckingHandler,false,0,true);
|
||||
}
|
||||
}
|
||||
else if(param1 == "uninitialized")
|
||||
{
|
||||
_sound = null;
|
||||
}
|
||||
}
|
||||
|
||||
override public function get bytesLoaded() : Number
|
||||
{
|
||||
return _sound ? _sound.bytesLoaded : NaN;
|
||||
}
|
||||
|
||||
override public function get bytesTotal() : Number
|
||||
{
|
||||
return _sound ? _sound.bytesTotal : NaN;
|
||||
}
|
||||
|
||||
private function bytesTotalCheckingHandler(param1:Event) : void
|
||||
{
|
||||
var _loc2_:LoadEvent = null;
|
||||
if(lastBytesTotal != _sound.bytesTotal)
|
||||
{
|
||||
_loc2_ = new LoadEvent("bytesTotalChange",false,false,null,_sound.bytesTotal);
|
||||
lastBytesTotal = _sound.bytesTotal;
|
||||
dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user