home *** CD-ROM | disk | FTP | other *** search
- class mx.controls.streamingmedia.MP3Player extends mx.controls.streamingmedia.AbstractPlayer
- {
- var _mediaUrl;
- var _soundHolder;
- var _positionOnLoad;
- var _listeners;
- var _sound;
- var _volume;
- var _recentPosition;
- var _loaded;
- static var STOP = -1;
- function MP3Player(aMediaUrl, aSoundHolder)
- {
- super();
- if(aMediaUrl == null || aSoundHolder == null)
- {
- }
- this._mediaUrl = aMediaUrl;
- this._soundHolder = aSoundHolder;
- this.init();
- }
- function willStop()
- {
- return this._positionOnLoad == mx.controls.streamingmedia.MP3Player.STOP;
- }
- function init()
- {
- this._listeners = new Array();
- this._sound = new Sound(this._soundHolder);
- this._volume = mx.controls.streamingmedia.StreamingMediaConstants.DEFAULT_VOLUME;
- var _loc4_ = Object(this._sound);
- _loc4_.player = this;
- this._sound.onSoundComplete = function()
- {
- var _loc3_ = Object(this);
- var _loc2_ = _loc3_.player;
- _loc2_.setPlaying(false);
- _loc2_.broadcastEvent("complete");
- };
- this._recentPosition = 0;
- this._loaded = false;
- this._positionOnLoad = mx.controls.streamingmedia.MP3Player.STOP;
- this.setPlaying(false);
- }
- function playStarted()
- {
- this._loaded = true;
- this.initializeVolume();
- if(this._positionOnLoad == mx.controls.streamingmedia.MP3Player.STOP)
- {
- this.stop();
- }
- else
- {
- this.play(this._positionOnLoad);
- }
- }
- function addListener(aListener)
- {
- this._listeners.push(aListener);
- }
- function removeAllListeners()
- {
- this._listeners.length = 0;
- }
- function broadcastEvent(status)
- {
- var _loc2_ = 0;
- while(_loc2_ < this._listeners.length)
- {
- this._listeners[_loc2_].handlePlayer(this,status);
- _loc2_ = _loc2_ + 1;
- }
- }
- function load()
- {
- this.setPlaying(true);
- this._positionOnLoad = mx.controls.streamingmedia.MP3Player.STOP;
- this._sound.loadSound(this._mediaUrl,true);
- this._sound.setVolume(0);
- }
- function play(startingPoint)
- {
- if(startingPoint == null)
- {
- startingPoint = this._recentPosition;
- }
- if(this._loaded)
- {
- this._sound.start(startingPoint);
- }
- else
- {
- this._positionOnLoad = startingPoint;
- this._sound.loadSound(this._mediaUrl,true);
- this._sound.setVolume(0);
- }
- this.setPlaying(true);
- }
- function pause()
- {
- this._recentPosition = this._sound.position / 1000;
- this._sound.stop();
- this.setPlaying(false);
- }
- function stop()
- {
- this._recentPosition = 0;
- this._sound.stop();
- this.setPlaying(false);
- }
- function getPlayheadTime()
- {
- var _loc2_ = !this.isPlaying() ? this._recentPosition : this._sound.position / 1000;
- return _loc2_;
- }
- function setPlayheadTime(aPosition)
- {
- this._recentPosition = aPosition;
- if(this.isPlaying())
- {
- this.play(aPosition);
- }
- }
- function getMediaUrl()
- {
- return this._mediaUrl;
- }
- function setMediaUrl(aUrl)
- {
- this._loaded = false;
- this._mediaUrl = aUrl;
- if(this.isPlaying())
- {
- this.play(0);
- }
- else
- {
- this._recentPosition = 0;
- this.load();
- }
- }
- function getVolume()
- {
- return this._volume;
- }
- function setVolume(aVol)
- {
- this._sound.setVolume(aVol);
- this._volume = aVol;
- }
- function initializeVolume()
- {
- this.setVolume(this._volume);
- }
- function getMediaBytesLoaded()
- {
- return this._sound.getBytesLoaded();
- }
- function getMediaBytesTotal()
- {
- return this._sound.getBytesTotal();
- }
- function getTotalTime()
- {
- var _loc2_ = this._sound.duration * this._sound.getBytesTotal() / this._sound.getBytesLoaded();
- return _loc2_ / 1000;
- }
- function bufferIsFull()
- {
- }
- function resizeVideo()
- {
- }
- function playStopped()
- {
- }
- function mediaLoaded()
- {
- }
- function close()
- {
- this._sound.stop();
- }
- function logError(error)
- {
- }
- function isSizeSet()
- {
- return false;
- }
- function isSizeChange()
- {
- return false;
- }
- function setSeeking(isSeeking)
- {
- }
- }
-