AudioPlayer

Kind of class: public class
Package:
Inherits from:
  • Sprite
Version: 11 Apr 2010 Displays % loaded during loading
30 Mar 2010 Now uses TextFormat objects for TextFields
7 Mar 2010
Author: John Polacek, john@johnpolacek.com
Classpath: com.johnpolacek.media.AudioPlayer
File last modified: Thursday, 24 February 2011, 22:09:57
Player for a single mp3 file
Example

  • Basic usage:
    import com.johnpolacek.media.AudioPlayer;
    var player:AudioPlayer = new AudioPlayer();
    player.titleColor = 0xAAAAAA;
    player.subtitleColor = 0x666666;
    player.titleText = "Song Name";
    player.subtitleText = "Artist Name;
    player.play("example.mp3");            // url of audio file
    
Events broadcasted to listeners
  • Event.COMPLETE # When load is complete.
  • Event.SELECT # When load is complete.
  • UIEvent.PLAYBACK_FINISH # When playback finishes.

Summary

Constructor
Instance properties
  • titleText : String
    • Text that displays in player's title TextField.
  • subtitleText : String
    • Text that displays in player's subtitle TextField.
  • titleTextFormat : TextFormat
    • The TextFormat for the title TextField.
  • subtitleTextFormat : TextFormat
    • The TextFormat for the subtitle TextField.
  • backgroundColor : uint
    • The TextFormat for the note TextField.
  • buttonColor : uint
    • Color of player buttons.
  • trackColor : uint
    • Player track color.
  • playerWidth : Number
    • Width (in pixels) of player.
  • playerHeight : Number
    • Height (in pixels) of player (not inluding progress bar).
  • audio : Sound
    • Sound to be played by player.
  • soundChannel : SoundChannel
    • SoundChannel of player.
  • autoPlay : Boolean
    • Default is false.
Instance methods

Constructor

AudioPlayer

function AudioPlayer()

Instance properties

audio

audio:Sound = null(read,write)

Sound to be played by player.

autoPlay

autoPlay:Boolean = false(read,write)

Default is false.

backgroundColor

backgroundColor:uint = 0x000000(read,write)

The TextFormat for the note TextField.

buttonColor

buttonColor:uint = 0xFFFFFF(read,write)

Color of player buttons. Default is 0xFFFFFF

playerHeight

playerHeight:Number = 50(read,write)

Height (in pixels) of player (not inluding progress bar). Default is 50

playerWidth

playerWidth:Number = 400(read,write)

Width (in pixels) of player. Default is 400

soundChannel

soundChannel:SoundChannel = new SoundChannel()(read,write)

SoundChannel of player.

subtitleText

subtitleText:String = ""(read,write)

Text that displays in player's subtitle TextField. Default is ""

subtitleTextFormat

subtitleTextFormat:TextFormat(read,write)

The TextFormat for the subtitle TextField.

titleText

titleText:String = ""(read,write)

Text that displays in player's title TextField. Default is ""

titleTextFormat

titleTextFormat:TextFormat(read,write)

The TextFormat for the title TextField.

trackColor

trackColor:uint = 0x666666(read,write)

Player track color. Default is 0x666666

Instance methods

destroy

function destroy() : void

load

function load(url:String, auto:Boolean = false) : void

Loads sound into player

Parameters
 

pauseAudio

function pauseAudio() : void

Pauses audio playback

playAudio

function playAudio() : void

Initiates audio playback

updatePlayerDisplay

function updatePlayerDisplay() : void

Updates player display