“Royal Audio Player ” Documentation by FWDesign


Royal Audio Player

Created: 05/10/2013
By:© FWD (FLASH WEB DESIGN)
Email: contact@webdesign-flash.ro

Thank you for purchasing our script. If you have any questions that are beyond the scope of this help file, please feel free to email via our email. Thanks so much!


Table of Contents

  1. Important notes read this before anything else.
  2. Preparing the audio files.
  3. Preparing SHOUTCAST.
  4. How to install Royal Audio Player into your html page.
  5. Constructor parameters.
  6. Setup playlists.
  7. Setup facebook share button.
  8. API.
  9. Sources and Credits

A) Important notes make sure you read this! - top

Please note that the Royal Audio Player installation and configuration is not complicated but because it has a lot of customizable settings it might seem complicated, please go through the entire documentation before trying to install it into your own page. Basically what it must be done is to copy some html code from the examples we provided and paste it into your own html page and of course add your own audio file.

The server is character case sensitive so make sure that the Royal Audio Player settings are identical to those from the provided examples.

When using mp3 files located on your server with relative paths you must add all folders that contains mp3's in the content folder, this is extremely important in order for all features to work correctly.

The server is character case sensitive so make sure that the Mp3 Sticky Player settings are identical to those from the provided examples.

Some of the features will not work local like the share button or loading xml playlist file, this is normal behavior because most browser does not allow this, once uploaded on the server it will function properly.

When something is wrong with a Royal Audio Player actions a red info box with the problem description will appear over the Royal Audio Player, please note that this box is there to help you understand the problem, for example if a mp3 file is not found the box will appear and inform you about the problem. The box can be closed when clicked or touched.

When testing local on IE7/IE8 or on an older browser that dose not support HTML5 audio it will not work because the flash (.swf) file is trying to comunicate with the browser and this is not allowed, of course it will work fine when tested online.

The Royal Audio Player skin is constructed from .png images, only a few settings for changing colors are possible like changing the playlist or title track color. If you want a different skin the .png files must be modified. The skin is really flexible this is allowing to skin the Royal Audio Player as you like. We have a great designer so if you need a custom skin please contact us!

B) Preparing the audio files. - top

Currently all browsers except Opera have .mp3 support (this applies to desktop), on a mobile device all browsers have .mp3 support. On a browser that does not have .mp3 support the player will use flash. The good news is that the player will work only with .mp3 files there is no need to use other audio formats.

B) Preparing SHOUTCAST. - top

In order to stream shoutcast instead on adding the mp3 file in the playlist add the shoutcast server address and at the end of it ;.mp3 , like this : http://95.141.24.224:80/;.mp3. Adding the ;.mp3 at the end of the address will force the server to serve the mp3 stream instead of the http web page. Please note that this player has support only for mp3 stream and it will not work correctly with other formats like .acc or .ogg. The good news is that the player will play the stream on all browser no matter which operating system is used, this applies to both mobile and desktop.

C) How to install Royal Audio Player into your html page. - top

This is a small tutorial about how to install the Royal Audio Player into your page. Royal Audio Player can be e embedded into a html page inside a div of your choosing, the Royal Audio Player will adapt its width based on the maxWidth property specified in the constructor, the height is set based on the controller height plus palylist height, if the page is resized and the parent div width is smaller then the maxWidth property the Royal Audio Player will adapt its size accordingly.

In the download files there is a start folder and in this folder there are html files starting with the label "skin", each of this examples have exactly the same structure with different constructor settings you can use one of them to copy and paste the required html code based on skin that you need, I will use the skin-minimal-dark.html as an example for this tutorial.

The skin is created using javascript and .png images, if you want a custom skin please contact us. If you want to create a skin of your own modify the ones we already provided.

This is how the player is installed in a HTML page, please read the Constructor parameters section to understand the Royal Audio Player properties

D) Constructor parameters. - top

Please open any of the .html files provided with a text editor as reference.

These parameters represents the possible setting for the Royal Audio Player they are all visible in the below image and described below.

//-- main settings --//

//-- controller settings --//

//-- playlists window settings --//

//-- playlist settings --// //-- popup settings --//

Setup playlists. - top

Open with a text editor one of the html files files starting with the label "skin" as reference.

Setting up the playlist window is simple, an ul tag must be added in the body tag, this ul tag must have an unique id that is passed as a value to the Royal Audio Player constructor as follows playlistsId"unique-id", in the examples provided the id is "playlists" but it can be have any value as long as it is unique.

To add/remove a playlist an li tags must be added/removed inside the playlists ul tag, this is illustrated in the below image. The Royal Audio Player supports unlimited playlists but at least one playlist is required!.

There are five playlist type as follow: HTML, PODCAST, XML, SOUNDCLOUD and OFFICIAL.FM playlist . Each of this type of playlists are explained in detail below.

SoundCloud playlist.

To add/remove this type of playlist in the playlists add or remove the code from the below image into the playlists ul tag. The data-source represents the url of a SoundCloud playlist. The other attributes are self explanatory.

OFFICIAL.FM playlist.

To add/remove this type of playlist in the playlists add or remove the code from the below image into the playlists ul tag. The data-source represents the custom string plus the the playlist id. An official.fm playlist url looks something like this "http://www.official.fm/playlists/yrOG?from=homepage&track_id=MjH0", what you need to get from the url is the playlist id showed in bold and add it after the special string like this official.fm/yrOG.

HTML playlist.

To add/remove this type of playlist in the playlists add or remove the code from the below image into the playlists ul tag.The data-source represents the id of the playlist ul element. The other attributes are self explanatory.

To construct this type of playlist add the code from the below image inside the body HTML element. The code sample is self explanatory. To add/remove tracks add/remove li HTML elements with the data-path attribute. If you don't need a thumbnail or duration remove the data-thumbpath and data-duration attributes.

FOLDER playlist.

To add/remove this type of playlist add or remove the code from the below image into the playlists ul tag.The data-source represents path of the mp3's folder (please note that this type of playlist can only be loaded form the same domain on which the html page resides, also the foler path must be relative to the path of the "proxyFolderPath.php", what this means is that your mp3's folder must be in the same folder or subfolder with the "proxyFolderPath.php" file ). The other attributes are self explanatory.

When adding the folder path to the data-source attribute a special string must be added before it, this string value is folder:, so for example if the mp3's folder path is myFolder the final string must look like this folder:myFolder. For a folder with a mp3's subfolder ex: myFolder/myMp3Folder the final string must look like this folder:myFolder/myMp3Folder .

XML playlist.

To add/remove this type of playlist in the playlists add or remove the code from the below image into the playlists ul tag. The data-source represents the path of the XML file. Please note that the XML path must be absolute, ex: http://www.domain.com/xmlFile.xml. The other attributes are self explanatory. Please note that the XML file does not allow special characters like "&", if you need to use this type of character numeric characters are required, a useful table with all this special characters can be found at this url.

To construct this type of playlist create an XML file with the same structure as the one from the below image (a sample XML file is included in the content folder). The code sample is self explanatory. To add/remove tracks add/remove li elements with the data-path attribute. If you don't need a thumbnail or duration remove the data-thumbpath and data-duration attributes.

PODCAST playlist.

To add/remove this type of playlist in the playlists add or remove the code from the below image into the playlists ul tag. The data-source represents the path of the PODCAST url.

Setup facebook share button. - top

In order for the facebook share button to function a facebook app key is required, this key is obtained by setting up a facebook app as follows:

One important thing to note is that the Royal Audio Player url must be identical with the url passed to the facebook app, for example if the Royal Audio Player url is http://www.some-domain.com and the facebook app is configured with the url http://some-domain.com it will not work, both url must be exactly the same.

API. - top

Inside the donwload files there is HTML file called API-example.html, in this file I have added all events and methods for reference, open the page source to see them. Full reference below. Please note that the properties are read only and they can only be written in the consturctor for more info about this please read the Constructor parameters section.

API - public methods:

Function Method Description

loadPlaylist

loadPlaylist(playlistId):void Load a playlist based on id, the playlist count starts from 0.

showCategories

showCategories():void Show the playlist selector window.

showPlaylist

showPlaylist():void Show the playlist.

hidePlaylist

hidePlaylist():void Hide the playlist.

share

share():void Share current track on facebook.

setVolume

setVolume( Number ):void Set the audio volume, this method accepts a parameter that represents a number between 0 (audio mute state) and 1 (audio maximum volume).

scrub

scrub( Number ):void Notify instance to scrub (set the audio position), this method accepts a parameter that represents a number between 0 (audio start position) and 1 (audio end position).

stop

stop():void Stops the playback and the loading process if the loading process has started.

play

play():void Start / play playback.

pause

pause():void Pause the playback.

playPrev

playPrev():void Play previous track.

playNext

playNext():void Play next track.

playShuffle

playShuffle():void Play shuffle track.

API - event listeners:

Event Prefix Description

ready

FWDAudioPlayer.READY

Dispatched when the Royal Audio Player instance API is actually available.

start

FWDAudioPlayer.START

Dispatched when the Mp3 playing has started.

popup

FWDAudioPlayer.POPUP

Dispatched when the player is pop-uped in a new window.

error

FWDAudioPlayer.ERROR

Dispatched when the Royal Audio Player instance can't load or play the audio file, this event has a property of type string that represents the error message.

startToLoadPlaylist

FWDRoyalAudioPlayer.START_TO_LOAD_PLAYLIST

Dispatched when the playlist loading has started.

playlistLoadCompleteHandler

FWDRoyalAudioPlayer.LOAD_PLAYLIST_COMPLETE

Dispatched when the playlist loading is complete.

stop

FWDAudioPlayer.STOP

Dispatched when the Royal Audio Player instance is stopped.

play

FWDAudioPlayer.PLAY

Dispatched when the Royal Audio Player instance playback start to play.

pause

FWDAudioPlayer.PAUSE

Dispatched when the Royal Audio Player instance playback is paused.

update

FWDAudioPlayer.UPDATE

Dispatched when the Royal Audio Player instance is playing and it's position is changing (useful to update a custom scrub bar), this event has a property of type number between 0 (audio start position) and 1 (audio end position).

updateTime

FWDAudioPlayer.UPDATE_TIME

Dispatched when the Royal Audio Player instance current duration is changing. This event has two properties of type string curTime and totalTime.

playComplete

FWDAudioPlayer.PLAY_COMPLETE

Dispatched when the Royal Audio Player instance playback has reached the end of the audio file.

API - methods:

Name Method Description

getIsAPIReady

getIsAPIReady():Boolean

Returns the API state, true if ready, false if not.

getCatId

getCatId():Number

Returns the current category id, the counting starts form 0.

getTrackId

getTrackId():Number

Returns the current track id, the counting starts form 0.

F) Sources and Credits - top

This component was made by Tibi from FWD (FWDesign) FLASH WEB DESIGN, for more information and support contact us at contact@webdesign-flash.ro

Once again, thank you so much for purchasing this item. As I said at the beginning, I'd be glad to help you if you have any questions regarding this Royal Audio Player and I'll do my best to assist.

FWDesign

Go To Table of Contents