e-China workspace AudioPlayer
\n');
}
var stopTimeout;
var TimeOver = 0;
//read all data from AR local data directory.
function readInitData(){
var flashobj = document.getElementById("audioplayer");
if (flashobj==null) {
flashobj=parent.InternetExplorer ? window.audioplayer : window.document.audioplayer;
}
var arobj=document.getElementById("AR");
if (arobj.SoundLocalPath=="" || arobj.SoundLocalPath=="/") {
flashobj.initAR();
}else{
var fileList="";
flashobj.loadAR();
fileList=arobj.ReadDataDirectory(true);
var tmpFile="";
while (fileList.indexOf('|')>0) {
tmpFile=fileList.substr(0,fileList.indexOf('|'));
tmpFile=tmpFile.substr(0,tmpFile.indexOf('.'));
flashobj.addExistedItem(tmpFile);
fileList=fileList.substr(fileList.indexOf('|')+1);
}
var divText=document.getElementById("ARPath");
regExp = new RegExp( "\/", "g");
divText.innerHTML = arobj.SoundLocalPath.replace(regExp,"\\");
}
}
function loadARData(){
var fileList="";
var flashobj = document.getElementById("audioplayer");
if (flashobj==null) {
flashobj=parent.InternetExplorer ? window.audioplayer : window.document.audioplayer;
}
var arobj=document.getElementById("AR");
if (arobj==null) {
arobj=parent.InternetExplorer ? window.AR : window.document.AR;
}
flashobj.loadAR();
fileList=arobj.ReadDataDirectory(true);
var tmpFile="";
while (fileList.indexOf('|')>0) {
tmpFile=fileList.substr(0,fileList.indexOf('|'));
tmpFile=tmpFile.substr(0,tmpFile.indexOf('.'));
flashobj.addExistedItem(tmpFile);
fileList=fileList.substr(fileList.indexOf('|')+1);
}
var divText=document.getElementById("ARPath");
re = new RegExp( "\/", "g");
divText.innerHTML = arobj.SoundLocalPath.replace(re,"\\");
}
function initARData(strPath){
var arobj=document.getElementById("AR");
if (arobj==null) {
arobj=parent.InternetExplorer ? window.AR : window.document.AR;
}
re = new RegExp("\\\\", "g");
strA=strPath.replace(re,"/");
arobj.SetLocalPath(strPath);
loadARData();
}
function callARBrowserFolder(){
var arobj=document.getElementById("AR");
if (arobj==null) {
arobj=parent.InternetExplorer ? window.AR : window.document.AR;
}
var strPath=arobj.GetBrowserPath();
var flashobj = document.getElementById("audioplayer");
if (flashobj==null) {
flashobj=parent.InternetExplorer ? window.audioplayer : window.document.audioplayer;
}
if ((strPath==null) || (strPath=="") ) {
return;
}else{
flashobj.setFolder(strPath);
}
}
function audioplayer_cmd(command, args){
var objAudio=document.getElementById("AR");
if (objAudio==null) {
objAudio=parent.InternetExplorer ? window.AR : window.document.AR;
}
var objMediaPlayer = document.getElementById("MediaPlayer");
if (objMediaPlayer==null) {
objMediaPlayer=parent.InternetExplorer ? window.MediaPlayer : window.document.MediaPlayer;
}
switch (command) {
case "record" :
//document.all.AR.PlayStatus=2;
objAudio.RecordSound(args);
break;
case "play":
if (objMediaPlayer) {
if (2==objMediaPlayer.playState) {
objMediaPlayer.controls.play();
}else {
objMediaPlayer.URL=objAudio.SoundLocalPath+"/"+args;
objMediaPlayer.controls.play();
}
}else {
alert("Can't loading Windows Media Player!");
}
break;
case "pause":
objMediaPlayer.controls.pause();
break;
case "rename":
oldname=args.substr(0,args.indexOf("|"));
newname=args.substr(args.indexOf("|")+1,args.length);
if (oldname==newname) {
alert('You can not renaming a file to the same name as an existing one!');
}else if(newname==""){
alert('You can not use empty file name!');
}else {
objAudio.RenameSound(oldname,newname);
}
break;
case "rewind":
objMediaPlayer.controls.stop();
break;
case "stop":
objAudio.StopSound(args);
break;
case "select":
//Not support in Moodle
break;
case "submit":
//Not support in Moodle
break;
case "delete":
objAudio.RemoveAudioFile(args);
break;
}
}
function stopTime(){
window.clearTimeout(stopTimeout);
}
function flAlert(str){
alert(str);
}
function resetARDirectory(){
var arobj=document.getElementById("AR");
if (arobj==null) {
arobj=parent.InternetExplorer ? window.AR : window.document.AR;
}
var strPath= arobj.GetBrowserPath();
ra = new RegExp( "\:\+\\\\", "g");
if (strPath==null || strPath=="") {
return;
}else if (!(strPath.match(ra))) {
alert("Please select a correct directory.\n e.g c:\\audioplayer");
return;
}
re = new RegExp( "\\\\", "g");
arobj.SetLocalPath(strPath.replace(re,"/"));
loadARData();
}
Requires Flash Player 7+. Please download from here