MP3 Player (AS 3.0) V. 1.0 Documentation
Properties
| Name | Type | Description |
| autoBuffer | Boolean | Determines whether the player should start buffering right when the page loads (true) or after the play method is called (false). Example myPlayer.autoBuffer = true; |
| autoPlay | Boolean | Determines whether the player begins playback right after the source is set (true) or not (false). Example myPlayer.autoPlay = false; |
| buffering | Boolean | Read only property indicates whether the player is currently buffering (true) or not (false). Example trace(myPlayer.buffering); |
| bufferTime | Number | Indicates the amount of time (in milliseconds) the player should buffer before playback starts. Example myPlayer.bufferTime = 1000; |
| bytesLoaded | uint | Read-only property indicates the number of bytes loaded from the current source. Example trace(myPlayer.bytesLoaded); |
| bytesTotal | uint | Read-only property indicates the total bytes of the current source. Example trace(myPlayer.bytesTotal); |
| mute | Boolean | Determines if the player is muted (true) or not (false). Example myPlayer.mute = true; |
| id3 | Object | Read-only property get the ID3 information as a Flash ID3Info object after the ID3_RECEIVED event has fired. Example import com.afcomponents.mp3player.events.MP3PlayerEvent; function onPlayerID3(event:MP3PlayerEvent):void { trace(myPlayer.id3.songName); } myPlayer.addEventListener(MP3PlayerEvent.ID3_RECEIVED, onPlayerID3); |
| playheadTime | Number | Read-only property indicates the current position of the playhead in seconds. Example trace(myPlayer.playheadTime); |
| source | String | Gets or sets the player's source. Requires a valid path to an MP3 file. Example myPlayer.source = "some_file.mp3"; |
| state | String | Read-only property indicates the current state of the player (playing, paused, stopped, etc). Example trace(myPlayer.state); |
| totalTime | Number | Read-only property indicates the total play time of the current loaded MP3 file. Note: this property can be set manually through the load method. Example trace(myPlayer.totalTime); |
| volume | Number | Gets or sets the player's volume (0 = 0%, 1 = 100%). Example myPlayer.volume = 0.7; |
Methods
| Name | Return Type | Description |
| abortLoad( ) | Void | Closes the currently loaded or loading sound. Note: call the stop() method if the player is currently playing to stop the current sound. Example myPlayer.abortLoad(); |
| load( source:String, totalTime:Number = 0 ) |
Void | Loads and MP3 file into the player. An optional paramater, totalTime, should be the length of the MP3 file in seconds and can be used for a more accurate seek bar. Example myPlayer.load("some_file.mp3", 120); |
| pause( ) | Void | Pauses MP3 playback. Example myPlayer.pause(); |
| play( ) | Void | Starts MP3 playback. Note: you should check if the player is already playing before calling this method. Example if(myPlayer.state != "playing") myPlayer.play(); |
| seekPercent( percent:Number ) | Void | Seeks to the specified location indicated by percent and begins playback. Known Issue The percent parameter expects a value of 0 - 100 instead of the standard AS3 method of expressing percentages from 0 - 1. Example myPlayer.seekPercent(50); |
| seekSeconds( seconds:Number ) | Void | Seeks to the location indicated by seconds and begins playback. Example myPlayer.seekSeconds(23); |
| stop( ) | Void | Stops MP3 playback. Example myPlayer.stop(); |
Events
| Name | Return Value | Description |
| BUFFERING_STATE_ENTERED | type target |
Triggered when the player enters the buffering state. Example import com.afcomponents.mp3player.events.MP3PlayerEvent; function onPlayerBuffering(event:MP3PlayerEvent):void { trace(event.type); } myPlayer.addEventListener(MP3PlayerEvent.BUFFERING_STATE_ENTERED, onPlayerBuffering); |
| BUFFERING_STATE_ENDED | type target |
Triggered when the player is finished buffering. Example import com.afcomponents.mp3player.events.MP3PlayerEvent; function onPlayerBufferingEnded(event:MP3PlayerEvent):void { trace(event.type); } myPlayer.addEventListener(MP3PlayerEvent.BUFFERING_STATE_ENDED, onPlayerBufferingEnded); |
| COMPLETE | type target |
Triggered when MP3 playback finishes. Example import com.afcomponents.mp3player.events.MP3PlayerEvent; function onPlayerComplete(event:MP3PlayerEvent):void { trace(event.type); } myPlayer.addEventListener(MP3PlayerEvent.COMPLETE, onPlayerComplete); |
| ID3_RECEIVED | type target |
Triggered when the player receives ID3 info from the loaded file. Note: Some files will not contain any ID3 information. Example import com.afcomponents.mp3player.events.MP3PlayerEvent; function onPlayerID3(event:MP3PlayerEvent):void { trace(event.type); } myPlayer.addEventListener(MP3PlayerEvent.ID3_RECEIVED, onPlayerID3); |
| READY | type target |
Triggered when the player is finished buffering and is ready to accept all commands (some commands can be used before the player is buffered.) Example import com.afcomponents.mp3player.events.MP3PlayerEvent; function onPlayerReady(event:MP3PlayerEvent):void { trace(event.type); } myPlayer.addEventListener(MP3PlayerEvent.READY, onPlayerReady); |
| PLAYHEAD_UPDATE | type target |
Triggered during playback to indicate playback progress. Example import com.afcomponents.mp3player.events.MP3PlayerEvent; function onPlayheadUpdate(event:MP3PlayerEvent):void { trace(event.type); } myPlayer.addEventListener(MP3PlayerEvent.PLAYHEAD_UPDATE, onPlayheadUpdate); |
| STATE_CHANGE | type target |
Triggered when the player's state changes. Example import com.afcomponents.mp3player.events.MP3PlayerEvent; function onPlayerStateChange(event:MP3PlayerEvent):void { trace(event.type); trace(myPlayer.state); } myPlayer.addEventListener(MP3PlayerEvent.STATE_CHANGE, onPlayerStateChange); |
| VOLUME_CHANGED | type target |
Triggered when the volume is changed. Example import com.afcomponents.mp3player.events.MP3PlayerEvent; function onPlayerVolumeChange(event:MP3PlayerEvent):void { trace(event.type); } myPlayer.addEventListener(MP3PlayerEvent.VOLUME_CHANGED, onPlayerVolumeChange); |
