Class mcPlayer
Version
1.01.
// --- #1 oMcPlayer=new mcPlayer(); oMcPlayer.init(); // draw player gui oMcPlayer.minimize(true); // ... and hide the gui without animation // --- #2 var oMcPlayer = new mcPlayer({ settings:{ autoopen: true, repeatlist: false } }); oMcPlayer.init(); // draw player gui oMcPlayer.minimize(); // ... and hide the gui
{Boolean} addAudio(aSong)
add a song to the playlist
{boolean} canPlaySurround()
Check: does the browser support 5.1 channels?
tablets and mobile devices: false
older Opera versions: false
all other: true
{undefined} disableRepeat()
disable playing option repeat playlist
{undefined} disableShuffle()
disable playing option shuffle playlist
{boolean} disableStatusbar()
disable playing option shuffle playlist
{undefined} enableRepeat()
enable playing option repeat playlist
{undefined} enableShuffle()
enable playing option shuffle playlist
{boolean} enableStatusbar()
enable playing option shuffle playlist
{float} getAllAudioChannels()
get an array of valid channels of the current song; if no song is active it returns false.
{integer} getAudioChannels()
get current count of channels of the current song you typically get "2.0" for stereo or "5.1" for surround
{float} getAudioDuration()
get duration in [sec] of the current song
{Integer|false} getAudioNetworkstate()
get network state of current audio (i.e. loading / idle) https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/networkState
{float} getAudioPosition()
get position in [sec] of the current song
{Integer|false} getAudioReadystate()
get document state of current audio https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/readyState
{float} getAudioSrc()
get used source url of the current song
{array} getPlaylist()
get playlist with all songtitles and its sources
{array} getPlaylistCount()
get playlist with all songtitles and its sources
{Number} getPlaylistId()
get id of the currently active song in the playlist (if shuffled)
{array} getPlayorder()
get playlist with all songtitles and its sources
{array} getSong()
get current song; you get an array with the song title and all its audio sources and mime types
{string} getSongAlbum()
get album of the currently active song
{string} getSongArtist()
get artist of the currently active song
{string} getSongBpm()
get publishing year of the currently active song
{string} getSongGenre()
get publishing year of the currently active song
{Number} getSongId()
get id of the currently active song; first song starts with 0; value -1 means player did not start to play yet.
{string} getSongImage()
get publishing year of the currently active song
{string} getSongTitle()
get title of the currently active song
{string} getSongUrl()
get url for the song i.e. where to buy it
{string} getSongYear()
get publishing year of the currently active song
{float} getVolume()
get current volume (a value between 0..1)
{boolean} init(sContainerId)
initialize player
{Boolean} isMuted()
get boolean value - volume is muted?
{Boolean} isPaused()
get boolean value - playing audio is paused?
{Boolean} isPlaying()
get boolean value - audio is playing? It returns true if audio is playing and false if paused or stopped.
{Boolean} isRepeatlist()
get boolean value - is shuffling mode on?
{Boolean} isShuffled()
get boolean value - is shuffling mode on?
{Boolean} isStopped()
get boolean value - playing audio is stopped
{Boolean} isStream()
get boolean value - is the curemt played audio a stream? remark: it is detected by audio.duration == Infinity (Chrome) or count of durationchange events (used in Firefox)
{Boolean} isVisibleBox(sBaseId)
return if a dialog box is visible
{Boolean} isVisibleBoxAbout()
return if about dialog box is visible
{Boolean} isVisibleBoxDownload()
return if download dialog box is visible
{Boolean} isVisibleBoxPlaylist()
return if playlist dialog box is visible
{Boolean} isVisiblePlayer()
return if player window is visible
{Boolean} isVisibleStatusbar()
return if player window is visible
{undefined} makeMainwindowMovable(bMove)
set if make the main player window is movable. This method is useful if you added drag and drop support (addi.min.js) for the windows but the main player is fixed on the bottom.
maximize()
show/ maximize the player GUI
<a href="#" onclick="oMcPlayer.maximize(); return false;">show the player</a>
{boolean} maximizeBox(sBaseId, bFast)
maximize a box; argument is a base id of a button or div
<button onclick="oMcPlayer.maximizeBox('download')">show Downloads</button>
minimize(bFast)
minimize player GUI and show a maximize icon
<a href="#" onclick="oMcPlayer.minimize(); return false;">hide player</a>
{boolean} minimizeBox(sBaseId, bFast)
minimize a box; argument is a base id of a button or div
<button onclick="oMcPlayer.minimizeBox('download')">hide Downloads</button>
playeraction(sAction)
handle actions of the player
{boolean} setAudioPosition(iTime)
Set a position of the currently playing audio; It returns the set position; if there is no audio it retuns false
<button onclick="oMcPlayer.setAudioPosition(180.33);">oMcPlayer.setAudioPosition(180.33)</button>
{boolean} setChannel(sChannelId)
set channels to switch between stereo/ surround
{boolean} setConfig(aCfg)
set config; override default vars
{boolean} setNextSong()
play next song in playlist; if the audio is the last element in the playlist the playlist will be shuffled (if shuffling is enabled). It starts the first audio if the playing option "repeat" is enabled.
<button onclick="oMcPlayer.setNextSong();">next song</button>
{boolean} setPreviousSong()
start playing the previous song in playlist (if the current audio is not the first played element)
<button onclick="oMcPlayer.setPreviousSong();">previous song</button>
{boolean} setSong(sSongId)
set a (new) song to play based on the position in document.
<a href="#" onclick="oMcPlayer.setSong(0); return false;">first song</a> <a href="#" onclick="oMcPlayer.setSong(1); return false;">second song</a>
{boolean} setVolume(iNewVol)
set volume; it works only if a song is playing
<button onclick="oMcPlayer.setVolume(0.75)">75%</button>
{boolean} toggleBoxAndButton(sBaseId, sMode, bFast)
toggle visibility of a box (download, playlist, about)
{undefined} toggleRepeat()
toggle playing option repeat playlist
{undefined} toggleShuffle()
toggle playing option shuffle playlist
{boolean} toggleStatusbar()
toggle playing option shuffle playlist
{undefined} updateOnResize()
update window positions if the browser is resized.
{Boolean} updateStatus()
get boolean value - is the curemt played audio a stream? remark: it is detected by audio.duration == Infinity (Chrome) or count of durationchange events (used in Firefox)