/***********************************************************************************************
   ,----------------,            ,---,
 /                   ',          |   |
|      ,       ,      |          |   |
|     | |     | |     |,--------,|   |,------, ,--,  ,--,,------,.---,___,      ,---,,------,
|     | |     | |     |   .--,   |   |  ,-,  | |  |  |  |   ___  |   ,--,_|     '___'', ----'
|     | |     | |     |   `__'   |   |  `_'  |,|  `,_/  |   ____,`   |    ,---, ,---, _`, `,
 `___/   `___/   `___/|   ,_____/ '__/`____/',_|`,___,' |`__________,'    '___' |   ||_____,|
                      |   |                          |  |                       |   |
                      |   |                         _|  |                    ,--'   ,
                       `--'                        `____'                    '_____/

     
     À¥ÆäÀÌÁö¿¡¼­ À©µµ¿ì ¹Ìµð¾î ÇÃ·¹ÀÌ¾î¸¦ Á¦¾îÇÏ±â À§ÇÑ API¸¦
     ÀÚ¹Ù½ºÅ©¸³Æ®¸¦ »ç¿ëÇØ¼­ ±¸ÇöÇÔ.

																						Ver 1.0 
*************************************************************************************************/



/**
 *	¹Ìµð¾îÇÃ·¹ÀÌ¾î °´Ã¼
 *	À¥¿¡¼­ »ý¼ºµÈ À©µµ¿ì¹Ìµð¾î ÇÃ·¹ÀÌ¾î¸¦ °¨½Î´Â °´Ã¼·Î ¸î°¡Áö Á¦¾îÇÔ¼ö¸¦ ±¸ÇöÇÑ´Ù.
 *	ÀÌ ÇÔ¼ö´Â º¹ÀâÇÑ Á¦¾î±â´ÉÀ» °£´ÜÈ÷ ÇØÁÖ°Å³ª ¹öÀü°£ È£È¯¼ºÀ» À¯ÁöÇØÁØ´Ù.
 *
 *	@param	wplayer: À©µµ¿ì¹Ìµð¾îÇÃ·¹ÀÌ¾î °´Ã¼
 *	@param	url: »ó¿µÇÒ µ¿¿µ»ó URL (»ý·«°¡´É)
 *	@param	isAutostart: ÀÚµ¿½ÇÇà¿©ºÎ, ÀÚµ¿½ÇÇà:true, ¾Æ´Ï¸é false (»ý·«°¡´É)
 */
function Mplayer(wplayer, url, isAutostart)
{
	// attributes /////////////////////////////////////////////////
	this.wplayer = null;
	this.url = null;
	this.isAuthostart = false;
	this.playlistCount = 0;


	// constructing ///////////////////////////////////////////////
	switch ( arguments.length )
	{
		case 3: this.isAuthostart = isAuthostart;
		case 2: this.url = url;
		case 1: this.wplayer = wplayer;
				break;

		case 0: throw "À©µµ¿ì¹Ìµð¾îÇÃ·¹ÀÌ¾î °´Ã¼°¡ ÁöÁ¤µÇÁö ¾Ê¾Ò½À´Ï´Ù.";
		default: throw "°´Ã¼»ý¼º½Ã ¸Å°³º¯¼ö °³¼ö°¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù.";
	}
}

// methods /////////////////////////////////////////////////////////////////////

/**
 *	µ¿¿µ»ó »ó¿µÀ» ½ÃÀÛÇÑ´Ù.
 *	@param url: »ó¿µÇÒ µ¿¿µ»ó URL, »ý·«ÇßÀ» ¶§¿¡´Â ÀÌÀü¿¡ ¼³Á¤µÈ °ÍÀÌ »ó¿µµÈ´Ù. (»ý·«°¡´É)
 */
Mplayer.prototype.play = function(url)
{
	if ( arguments.length == 1 ) this.url = url;
	if ( this.url == null && this.playlistCount == 0 ) throw "µ¿¿µ»ó URLÀÌ ¼³Á¤µÇÁö ¾Ê¾Ò½À´Ï´Ù.";

	this.wplayer.url = url;
	this.wplayer.controls.play();
}

/**
 *	µ¿¿µ»ó »ó¿µÀ» ÁßÁöÇÑ´Ù.
 */
Mplayer.prototype.stop = function()
{
	this.wplayer.controls.stop();
}

/**
 *	Àç»ýÀ» Àá½Ã ¸ØÃá´Ù.
 *	¿øµµ¿ì¹Ìµð¾îÇÃ·¹ÀÌ¾î ¹ö±×ÀÎÁö´Â ¸ð¸£³ª playlist¿¡¼­ ÀÛµ¿ÇÏÁö ¾Ê´Â´Ù. TT
 */
Mplayer.prototype.pause = function()
{
	this.wplayer.controls.pause();
}

/**
 *	Àç»ýÀ» ´Ù½Ã ½ÃÀÛÇÑ´Ù.
 */
Mplayer.prototype.resume = function()
{
	this.wplayer.controls.play();
}


/**
 *	append new MP
 *	@param url: Ãß°¡ÇÒ µ¿¿µ»ó
 */
Mplayer.prototype.appendMedia = function(url)
{
	var	item = this.wplayer.newMedia(url);

	if ( this.wplayer.currentPlayList.name != "**chosun**" ) this.wplayer.currentPlayList = this.wplayer.newPlayList("**chosun**", "");
	this.wplayer.currentPlayList.appendItem(item);
	this.playlistCount++;
}

/**
 *	remove MP
 *	@param url: Á¦°ÅÇÒ µ¿¿µ»ó
 */
Mplayer.prototype.removeMedia = function(url)
{
	var	item = this.wplayer.newMedia(url);
	this.wplayer.currentPlayList.removeItem(item);
	this.playlistCount--;
	if ( this.playlistCount < 0 ) this.playlistCount = 0;
}

/**
 *	¸ðµç Àç»ý item À» Á¦°ÅÇÑ´Ù.
 */
Mplayer.prototype.removeAll = function()
{
	while(this.wplayer.currentPlaylist.count > 0) 
	{
		this.wplayer.currentPlayList.removeItem(this.wplayer.currentPlaylist.item(0));
	}
}

/**
 *	ÀüÃ¼È­¸é º¸±â·Î ÀÌµ¿ÇÑ´Ù.
 */
Mplayer.prototype.fullScreen = function()
{
	if ( this.wplayer.playState == 3 ) this.wplayer.fullScreen = 'true';
}



