Packagecom.nocreativity.playr
Classpublic class Playr
InheritancePlayr Inheritance flash.events.EventDispatcher

Playr class by Ronny Welter.
Makes creating a music player easy.
Author: Ronny Welter
URL: http://www.noCreativity.com
Mail: senderHas[at]noCreativity.com

The Playr class can be used to create easily a music player in your application/site using only a few lines of code.
Playr takes the heavy lifting off your hands, while you can just create cool things. Every type of application is possible starting from just playing a loop to the core of a full blown audio player.



Public Properties
 PropertyDefined by
  album : String
[read-only] Returns the artist of the now playing track.
Playr
  artist : String
[read-only] Returns the artist of the now playing track.
Playr
  autoPlay : Boolean
Gets or sets the autoplay property.
Playr
  currentSeconds : Number
[read-only] Returns the current amount of seconds of the track that have already been played as a number (for mathematical purposes).
Playr
  currentTime : String
[read-only] Returns the current time of the track in a human readable format.
Playr
  panning : Number
Sets the panning (left and right speakers) of the music.
Playr
  playlist : PlaylistManager
Returns the interal playlist.
Playr
  playrState : String
[read-only] Public properties
Playr
  repeat : String = "repeat_none"
Playr
  shuffle : Boolean
[write-only] Gets or sets the shuffle property of the Playr instance.
Playr
  title : String
[read-only] Returns the title of the now playing track.
Playr
  totalSeconds : Number
[read-only] Returns the total number of seconds of the now playing track.
Playr
  totalTime : String
[read-only] Returns the duration of the now playing track in a human readable format.
Playr
  trackDirectory : String = ""
Playr
  volume : Number
Gets or sets the volume.
Playr
Public Methods
 MethodDefined by
  
Playr(playlistURL:String = "", trackDirectory:String = "", autoPlay:Boolean = false, shuffle:Boolean = false, repeat:String)
Public methods
Playr
  
destroy():void
Removes all eventlisteners from the Playr instance.
Playr
  
fade(time:Number, startVolume:Number, targetVolume:Number):void
Fades the music from one volume to another over a given time frame.
Playr
  
fadeIn(time:Number = 2, targetVolume:Number = 1):void
Fades the music in (from 0 to a chosen target.
Playr
  
fadeOut(time:Number = 2):void
Fades the music out (from the current volume level to 0)
Playr
  
jumpToTrack(trackNumber:Number):void
Jumps to the track of your choice in the playlist.
Playr
  
loadPlaylist(playlistpath:String):void
Load a XML playlist.
Playr
  
loadTrackFromURL(filename:String):void
Loads a single track.
Playr
  
next():void
Advances the playlist to the next track.
Playr
  
pause():void
Pauses the now playing track.
Playr
  
play():void
Starts playing the loaded song or the playlist.
If a playlist has been loaded, the singleTrack property will change to false.
Playr
  
playTrack(track:PlayrTrack):void
Playr
  
previous():void
Moves the playlist to the previous track.
Playr
  
registerMuteButton(button:DisplayObject):void
Adds the toggleMute() method to a DisplayObject of your choice.
Playr
  
registerNextButton(button:DisplayObject):void
Adds the next() method to a DisplayObject of your choice.
Playr
  
registerPauseButton(button:DisplayObject):void
Adds the pause() method to a DisplayObject of your choice.
Playr
  
registerPlayButton(button:DisplayObject):void
Adds the play() method to a DisplayObject of your choice.
Playr
  
registerPreviousButton(button:DisplayObject):void
Adds the previous() method to a DisplayObject of your choice.
Playr
  
registerStopButton(button:DisplayObject):void
Adds the stop() method to a DisplayObject of your choice.
Playr
  
scrobbleTo(target:Number):void
Scrobbles through the track.
Playr
  
stop():void
Stops the now playing track.
Playr
  
toggleMute():void
Toggles the mute of the Playr instance.
Playr
Property detail
albumproperty
album:String  [read-only]

Returns the artist of the now playing track. This information is taken only from the playlist.

Implementation
    public function get album():String
artistproperty 
artist:String  [read-only]

Returns the artist of the now playing track. This information is taken only from the playlist.

Implementation
    public function get artist():String
autoPlayproperty 
autoPlay:Boolean  [read-write]

Gets or sets the autoplay property.

Implementation
    public function get autoPlay():Boolean
    public function set autoPlay(value:Boolean):void
currentSecondsproperty 
currentSeconds:Number  [read-only]

Returns the current amount of seconds of the track that have already been played as a number (for mathematical purposes).

Implementation
    public function get currentSeconds():Number
currentTimeproperty 
currentTime:String  [read-only]

Returns the current time of the track in a human readable format. Example: 2 minutes 16 seconds is '2:16'.

Implementation
    public function get currentTime():String
panningproperty 
panning:Number  [read-write]

Sets the panning (left and right speakers) of the music.

Implementation
    public function get panning():Number
    public function set panning(value:Number):void
playlistproperty 
playlist:PlaylistManager  [read-write]

Returns the interal playlist. This is an array consisting of all PlayrTracks.

Implementation
    public function get playlist():PlaylistManager
    public function set playlist(value:PlaylistManager):void
playrStateproperty 
playrState:String  [read-only]

Public properties

Implementation
    public function get playrState():String
repeatproperty 
public var repeat:String = "repeat_none"
shuffleproperty 
shuffle:Boolean  [write-only]

Gets or sets the shuffle property of the Playr instance. Shuffle in Playr 2.0 is smart. It remembers the previous tracks. Internally there is a secondary playlist.

Implementation
    public function set shuffle(value:Boolean):void
titleproperty 
title:String  [read-only]

Returns the title of the now playing track. This information is taken only from the playlist.

Implementation
    public function get title():String
totalSecondsproperty 
totalSeconds:Number  [read-only]

Returns the total number of seconds of the now playing track. This information is taken only from the playlist.

Implementation
    public function get totalSeconds():Number
totalTimeproperty 
totalTime:String  [read-only]

Returns the duration of the now playing track in a human readable format. Example: 2 minutes 16 seconds is '2:16'. This information is taken from the playlist.

Implementation
    public function get totalTime():String
trackDirectoryproperty 
public var trackDirectory:String = ""
volumeproperty 
volume:Number  [read-write]

Gets or sets the volume.

Implementation
    public function get volume():Number
    public function set volume(value:Number):void
Constructor detail
Playr()constructor
public function Playr(playlistURL:String = "", trackDirectory:String = "", autoPlay:Boolean = false, shuffle:Boolean = false, repeat:String)

Public methods

Parameters
playlistURL:String (default = "")
 
trackDirectory:String (default = "")
 
autoPlay:Boolean (default = false)
 
shuffle:Boolean (default = false)
 
repeat:String
Method detail
destroy()method
public function destroy():void

Removes all eventlisteners from the Playr instance.

fade()method 
public function fade(time:Number, startVolume:Number, targetVolume:Number):void

Fades the music from one volume to another over a given time frame.

Parameters
time:Number
 
startVolume:Number
 
targetVolume:Number
fadeIn()method 
public function fadeIn(time:Number = 2, targetVolume:Number = 1):void

Fades the music in (from 0 to a chosen target. If you don't give up a target volume, the fade will go from 0 to 1)

Parameters
time:Number (default = 2)
 
targetVolume:Number (default = 1)
fadeOut()method 
public function fadeOut(time:Number = 2):void

Fades the music out (from the current volume level to 0)

Parameters
time:Number (default = 2)
jumpToTrack()method 
public function jumpToTrack(trackNumber:Number):void

Jumps to the track of your choice in the playlist.

Parameters
trackNumber:Number
loadPlaylist()method 
public function loadPlaylist(playlistpath:String):void

Load a XML playlist. Once loaded the internal playlist is populated with PlayrTrack objects.

Parameters
playlistpath:String
loadTrackFromURL()method 
public function loadTrackFromURL(filename:String):void

Loads a single track. There is no ID3 information loaded. The trackprogress/streamprogress events aren't accurate (The progress will be 0 at all times). This method is mostly designed to be used with anonymous loops.

Parameters
filename:String — The path to the mp3 file, you want to play.
next()method 
public function next():void

Advances the playlist to the next track. If the current track is the last track in the playlist, the playlist jumps to the first track of the playlist.

pause()method 
public function pause():void

Pauses the now playing track.

play()method 
public function play():void

Starts playing the loaded song or the playlist.
If a playlist has been loaded, the singleTrack property will change to false. If a single track has been loaded, the singleTrack property will change to true.

playTrack()method 
public function playTrack(track:PlayrTrack):voidParameters
track:PlayrTrack
previous()method 
public function previous():void

Moves the playlist to the previous track. If the current track is the first track, the playlist jumps to the last track of the playlist.

registerMuteButton()method 
public function registerMuteButton(button:DisplayObject):void

Adds the toggleMute() method to a DisplayObject of your choice.

Parameters
button:DisplayObject
registerNextButton()method 
public function registerNextButton(button:DisplayObject):void

Adds the next() method to a DisplayObject of your choice.

Parameters
button:DisplayObject
registerPauseButton()method 
public function registerPauseButton(button:DisplayObject):void

Adds the pause() method to a DisplayObject of your choice.

Parameters
button:DisplayObject
registerPlayButton()method 
public function registerPlayButton(button:DisplayObject):void

Adds the play() method to a DisplayObject of your choice.

Parameters
button:DisplayObject
registerPreviousButton()method 
public function registerPreviousButton(button:DisplayObject):void

Adds the previous() method to a DisplayObject of your choice.

Parameters
button:DisplayObject
registerStopButton()method 
public function registerStopButton(button:DisplayObject):void

Adds the stop() method to a DisplayObject of your choice.

Parameters
button:DisplayObject
scrobbleTo()method 
public function scrobbleTo(target:Number):void

Scrobbles through the track.

Parameters
target:Number
stop()method 
public function stop():void

Stops the now playing track.

toggleMute()method 
public function toggleMute():void

Toggles the mute of the Playr instance.