RealPlayer埋め込みWeb再生方法とタイムトリガーについて説明します.


<script>
//---------            ,       ------//
var RS = new Array("rm","ram","mp3","ra","asf","rp","rmm","png","m3u","mp2","mpa","rmvb","smil","smi");
//-----------     -------------//
var Rstate = new Array("  ","  ","  ","  ","  ");

var player_doing = false; 

function choose_player(sound_path)
{
 	sound_path = sound_path.split(".");
 
 	var sound_type = sound_path[sound_path.length-1].toLowerCase();
 
	 for(i=0;i<RS.length;i++)
	 {
	  if(sound_type==RS[i])
	   return "R"
	 }
 
 	return "U";
}
function Do_play()
{
 var the_player  = document.getElementById("player");
 the_player.DoPlay();
}
function Do_pause()
{
 var the_player  = document.getElementById("player");
 the_player.DoPause();
}
function Do_stop()
{
 var the_player  = document.getElementById("player");
 the_player.DoStop();
}
function Set_position(num)
{
 	var the_player  = document.getElementById("player");
 	the_player.SetPosition(num);
}
function Get_position()
{
 	var the_player  = document.getElementById("player");
 	return the_player.GetPosition();
}
function Get_length()
{
	var the_player  = document.getElementById("player");
 	return the_player.GetLength();
}
function  Set_volume(num)
{
 	var the_player  = document.getElementById("player");
 	the_player.SetVolume(num);
}
function Show_time(num)
{
 	var time_minute = Math.floor( num / 60000 );
 	var time_second = Math.floor( ( num - time_minute*60000 ) / 1000 );
 
 	if( time_minute < 10 )
  		time_minute = "0" + time_minute;
 	if( time_second < 10 )
  	time_second = "0" + time_second;
  
 	return (time_minute + ":" +time_second);  
}
function Get_state()
{
	 var the_player  = document.getElementById("player");
	 return the_player.GetPlayState();
}

function player_play()
{
 var just_type = choose_player(document.getElementById("sound_path").innerHTML);
 var the_player  = document.getElementById("player");
 
 var the_state   = Get_state();
 
 
 if(the_state==1||the_state==2||the_state==3)
 {
  return;
 }
 
 if(the_state==4)
 {
  Do_play();
 }
   
 if(the_state==0)
 {
  if(just_type=="R")
  {
   Do_stop();
   the_player.SetSource(document.getElementById("sound_path").innerHTML);   
   Do_play();
   
   if(player_doing) 
   {
    clearInterval(player_doing)
   }
  
   player_doing = setInterval("Set_all()",500);   
  }
 } 
}
function Set_all()
{
 var the_player  = document.getElementById("player");
 
 document.getElementById("position_box").innerHTML = Show_time(Get_position());
 document.getElementById("length_box").innerHTML = Show_time(Get_length());
 
 document.getElementById("state_box").innerHTML    = Rstate[Get_state()];
 
 var the_max = (document.getElementById("position_button_box").offsetWidth - document.getElementById("position_button").offsetWidth);
 
 document.getElementById("position_button").style.pixelLeft = Math.round(the_max*Get_position()/Get_length());
 
 if(Get_state()==0)
 {
  clearInterval(player_doing);
 }
}
function Go_direction(num)
{
 var the_player  = document.getElementById("player");
 
 var the_state   = Get_state();
 
 if(the_state==3)
 {
  var the_direction = num*1000;
  
  var judger = (Get_position() + the_direction)
  
  if(judger>=0&&judger<=Get_length())
  {
    Set_position(judger);  
  } 
 } 
 
}

var Ox,Nx;
var move_obj_can_move = false;
var move_obj = false;
function start_move()
{
 	move_obj_can_move = true;
 
 	move_obj = event.srcElement.id;
 
 	document.getElementById(move_obj).setCapture(); 
  	Ox = event.clientX; 
 
}
function document.onmouseup()
{
 if(!move_obj)
  return;
  
 document.getElementById(move_obj).releaseCapture();
 
 move_obj_can_move = false;
 
 move_obj = false;
}
function document.onmousemove()
{
 if(!document.getElementById(move_obj))
 {
  return;
 }
//               
 if(move_obj=="position_button"&&(Get_state()!=3&&Get_state()!=4))
 {
  return;
 }
 Nx = event.clientX;
 
 var judger = document.getElementById(move_obj).style.pixelLeft + Nx - Ox;
 
 
 var max = document.getElementById(move_obj+"_box").offsetWidth - document.getElementById(move_obj).offsetWidth;
  
 if(!move_obj_can_move||!move_obj||judger>max||judger<0)
 {
  return;
 } 
 
  document.getElementById(move_obj).style.pixelLeft += Nx - Ox;
 
  eval(move_obj+"_event("+document.getElementById(move_obj).style.pixelLeft+","+max+")");
 
 Ox = Nx;
 
}
function volume_button_event(s_num,b_num)
{
 var judger = Math.round(100*s_num/b_num)
 
 if(judger>=0&&judger<=100)
 {
  Set_volume(judger)
 }
}
function position_button_event(s_num,b_num)
{
 var judger = Math.round(Get_length()*s_num/b_num);
 
 if(judger>=0||judger<=Get_length())
 {
  Set_position(judger)
 }
}
function changeurl()
{
	var url="http://liudechao-pc:7070/ramgen//flash.smi";
	var the_player  = document.getElementById("player");
	document.getElementById("sound_path").innerHTML=url;
	//the_player.SetSource(document.getElementById("sound_path").innerHTML);
	player_play();
}

</script>
 
<table  align="center" border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center">
    <OBJECT ID="player" CLASSID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="350" height="300"  >
    <param name="CONTROLS" value="ImageWindow">
    <embed src="" type="audio/x-pn-realaudio">
    </OBJECT>	
    <script event="OnStateChange(old,new)" for="player" language="javascript">
	if(new==0&& old==3) alert("Over!");
            </script>
    </td>
  </tr>
</table>
<table border="1" cellpadding="0" cellspacing="0" align="center" bordercolor="#CCCCCC"bgcolor="#6699CC">
<td>
<input id="change" value="Change Audio" type="button" onClick="changeurl()">
</td>
</table>
<div class="AudioPlayer" id="musicPlayer">
<table align="center">
<tr>
<td height="15" width="120">
<a onClick="player_play()" title="Play" href="javascript:void(0)">
  <img alt="Play" src="/jlpt/JLPT/gif/play.gif" width="15" height="15"></a>
<a onClick="Do_pause()" title="Pause" href="javascript:void(0)">
  <img alt="Pause" src="/jlpt/JLPT/gif/Pause.gif" width="15" height="15"></a>
<a onClick="Do_stop()" title="Stop" href="javascript:void(0)">
  <img alt="Stop" src="/jlpt/JLPT/gif/stop.gif" width="15" height="15"></a>
<a onClick="DoNextEntry()" title="Back" href="javascript:void(0)">
  <img alt="Back" src="/jlpt/JLPT/gif/skipback.gif" width="15" height="15"></a>
<a onClick="DoPrevEntry()" title="Next" href="javascript:void(0)">
<img alt="Next" src="/jlpt/JLPT/gif/skip.gif" width="15" height="15"></a>
<!--
          ,        ,                                
!-->
</td>
<td id="position_button_box" bgcolor="#C0C0C0" width="300">
<input id="position_button" type="button" style="position: relative; left:0; height: 20; width:10" 					onmousedown="start_move()">
</td>
<td id="position_box" width="40" bgcolor="#6699FF" align="center"></td>
<td id="length_box" width="40" bgcolor="#6699FF" align="center"></td>
<td id="state_box" width="40" bgcolor="#6699FF"align="center"></td>
<td id="audio"><a><img src="/jlpt/JLPT/gif/audio.gif" width="15" height="15"></a></td>
<td id="volume_button_box" width="100" bgcolor="#C0C0C0">
<input id="volume_button" type="button" style="position: relative; left:20; height:20; width: 10" 
onMouseDown="start_move()"> 
</td>
</tr>
</table>
</div>
<div style="visibility:hidden" id="sound_path">http://localhost:7070/ramgen//shiyueweicheng.rmvb</div>
 jsスクリプトはRealPlayerが提供する方法で制御し、HTMLスクリプトはいくつかの美化面での表示を行う.
放送終了後のイベントトリガもしました.realウェブページの埋め込みの1つの問題:プレイリストに対してramなどはできません.
シーケンス再生(最初の曲が非常に連続していません)、ソリューションはsmilを使ってすべてのファイルを一つのファイルに結合します.
しかし、この解決策の弊害は、次のボタンまたは前のボタンが使えなくなり、順番にしか再生できません.
PS:中国語版のウェブページに埋め込まれたREALに関する公式説明を見つけました.添付ファイルを見てから、ネットで探す必要はありません.