码迷,mamicode.com
首页 > 其他好文 > 详细

2016/1/16音频播放器

时间:2016-01-16 14:19:44      阅读:311      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script type="text/javascript">
        function el(objname){
            return document.getElementById(objname);
        }
        //添加歌曲到播放列表
        function addmedia(url){
            var playList = Player.currentPlayList;
            var currentUrl = player.newMedia(url);
            playList.appendItem(currMedia);
        }
        //清空播放列表
        function clearLists(){
            //返回列表中的歌曲数目
            while(Play.currentPlayList.count>0){
                var item = Player.currentPlayList.item(Play.currentPlayList.count-1);
                Player.currentPlayList.removeitem(item);
            }
        }
        function clearPlayList(){
            clearLists();
            var L_tb = el("tabPlayList");
            var row_len = L_tb.rows.length;
            for(var i;i<row_len;i++){
                L_tb.firstChild.removeChild(L_tb.firstChild.childNodes[0]);
            }
        }
        //清空媒体播放列表
        function clearMediaList(){
            var L_tb = el("tabMediaList");
            var row_len =L_tb.rows.length;
            for(var i;i<row_len;i++){
                L_tb.firstChild.removeChild(L_tb.firstChild.childNodes[0]);
            }
        }
        //播放选中歌曲
        function addSelectedSongToPlayList(){
            clearLists();
            var L_tb = el("tabPlayList");
            var row_len = L_tb.rows.length;
            if(row_len == 0){
                alert("There is no song");
                return;
            }
            for(var i;i<row_len;i++){
                var check = L_tb.rows[i].cell[0].childNodes[0];
                var songName = L_tb.rows[i].cells[1].innerText;
                if(check.checked == true){
                    addmedia(songName);
                }
            }
            setPlayMode(el("setplay").options[el("setplay").selectedIndex].value);
            Player.controls.play();
        }
        ////添加文本输入框中的url到播放列表
        function addUrlToList(){
           //addmeida(document.getElementById("songUrl").value);
            var L_tb = el("tabMediaList");
            var row_len = L_tb.rows.length;
            var tr = document.createElement("tr");
            var td = document.createElement("td");
            var strSong = el("songUrl").value;
            var strHtml = strSong + "&nbsp;<a href=‘#‘ onclick=‘addSong("" + strSong + "");‘>添加</a>";
            strHtml += "&nbsp;<a href=‘#‘ onclick=‘removeSong(this.parentElement.parentElement);‘>移除</a>";
            td.innerHTML = strHtml;
            tr.appendChild(td);
            l_tb.firstChild.appendChild(tr);

            el("songURL").value = "http://";
        }
        ////添加文本输入框中的url到播放列表
        function addSong(strSngName){
            var L_tb = el("tabPlayList");
            var row_len = L_tb.rows.length;
            var tr = document.createElement("tr");
            var td = document.createElement("td");
            var strChecked = "<input type=‘checkbox‘ checked value=‘"+ strSongNameqwe+"‘>";
            td.innerHTML = strChecked;
            tr.appendChild(td);
            td.innerHTML = strSngName;
            tr.appendChild(td);
            var strHTML = "&nbsp;<a href=‘#‘ onclick=‘removePlaySong(this.parentElement.parentElement)‘>remove</a>";
        }
            td.innerHTML = strHtml;
            tr.appendChild(td;
            tr.firstChild.appendChild(td);
        }
        //从媒体列表删除
        function removeSong(tr){
            var L_tb = el("tabMediaList");
            L_tb.firstChild.removeChild(tr);

        }
        //从播放列表删除
        function removePlaySong(tr){
            var L_tb = el("tabPlayList");
            L_tb.firstChild.removeChild(tr);
        }
        //到指定位置播放
        function palyPosition(){
            Player.controls.currentPosition = parseFloat(el("txtPosition").value);
            el("txtPosition").value = "1.0";
        }
        function startMeup(){Player.controls.play()};
        function startMeDown(){Player.controls.stop()};
        function Next(){Player.controls.next()}
        function Prev(){Player.controls.previous()}
        function Forward(){Player.controls.fastForward()}
        function reverse(){Player.controls.fastReverse()}
        function SetPlayMode(value){Player.settings.setMode(value,true)}
        function showMode(value){Player.uiMode=value;}
        function ajustSound(){
            if(event.srcElement.name=="turnup" && Player.settings.volume<=100)
            {Player.settings.volume+=10}
            if(event.srcElement.name=="turndown" && Player.settings.volume>=0)
            {Player.settings.volume-=10}
        }
    </script>
    <script type="text/javascript">
        el("currentMediaName").innerText = Player.currentMedia.name;
        el("currentMediaDuration").innerText = Player.currentMedia.durationString;
        el("currentMediaWidth").innerText = Player.currentMedia.imageSourceWidth;
        el("currentMediaHeight").innerText = Player.currentMedia.imageSourceHeight;
        el("currentMediaMarkerCount").innerText = Player.currentMedia.markerCount;
        el("currentSourceURL").innerText = Player.currentMedia.sourceURL;
    </script>
</head>
<body>
<object id = "player" width="400px" height="400px" classid="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6">
  <param value="URL" name="test.vmv">
  <param value="1" name="autoStart">
  <param value="0" name="balance">
  <param value name="baseUrl">
  <param value name="captioningID">
  <param value="0" name="currentPosition">
  <param value="0" name="currentMarker">
  <param value="0" name="defaultFrame">
  <param value="1" name="enabled">
  <param value="0" name="enableErrorDialogs">
  <param value="1" name="enableContentMenu">
  <param value="1" name="invokeUrls">
  <param value="0" name="mute">
  <param value="1" name="playCount">
  <param value="1" name="rate">
  <param value name="SAMIStyle">
  <param value name="SAMILang">
  <param value name="SAMIFilename">
  <param value="0" name="stretchToFit">
  <param value="full" name="uiMode">
  <param value="100" name="volume">
  <param value="0" name="windowlessVideo">
</object>
<br>
<input type="button" value="播放" onclick="startMeUp()" name = "btn-start">
<input type="button" value="停止" onclick="stopMeDown()" name = "btn-stop">
<input type = "button" value = "暂停" onclick = "Pause()" name = "btn-pause">
<label>
    <input type="button" name = "turnUp" id = "turnUp" onclick = "ajustSound()" value="+">
    调整声音
    <input type="button" name = "turnDown" id = "turnDown" onclick = "ajustSound()" value="-">
</label>
<br>
<input type="button" name = "btn-next" id = "next" value="下一首" onclick = "Next()">
<input type = "button" name = "btn-prev" id = "prev" value = "上一首" onclick="Prev()">
<input type="button" name = "btn-forw" id = "forward" value="快进" onclick="Forwad()">
<input type="button" name = "btn-back" id = "back" value="快退" onclick="Back()">
<br>
<label>播放模式</label>
<select id = "playMethod" name = "playMethod" onchange="setPlayMode(this.options[this.selectedIndex].value)">
    <option value="loop">循环播放</option>
    <option value="free">随机播放</option>
</select>
<label>显示模式</label>
<select id = "show" name = "show" onchange = "showMode(this.options[this.selectedIndex].value)">
    <option value="none">none</option>
    <option value="mini">mini</option>
    <option value="hidden">hidden</option>
    <option value = "full" selected>full</option>
</select>
<br><br>
媒体列表:<br>
<div id = "MediaList">
    <table id = "tabMediaList">
    </table>
</div>
播放列表:<br>
<div id = "PlayList">
    <table id = "tabPlayList"></table>
</div>
当前播放媒体信息:<br>
名称:<span id = "currentMediaName"></span><br>
长度:<span id = "currentMeidiaDuration"></span>秒<br>
宽度:<span id = "currentMeidaWidth"></span>像素<br>
高度:<span id = "currentMediaHeight"></span>像素<br>
标志数:<span id = "currentMeidaMarkerCount"></span><br>
源地址:<span id = "currntSourceUrl"></span><br>
<br><br>
<input type = "button" name = "play" id = "play" value = "播放选中的歌曲" onclick = "addSelectedSongToPlayList()">
<input type = "button" name = "clear" id = "clear" value = "清空播放列表" onclick = "clearPlayList()">
<inpit type = "button" name = "clear" id = "clear" value = "清空媒体列表" onclick = "clearMediaList()">
<br><br>
<input type="text" name = "songUrl" value="http://" size = "33">
<input type = "button" name = "add" id = "add" value = "添加到媒体播放列表" onclick = "addUrlToList()">
<br><br>
    <input type="button" onclick = "alert(Player,versioninfo)" value = "播放器版本">
    <input type="button" onclick = "alert(Player.controls.currentPosition)" value="加载当前位置">
    跳到:<input type="text" id="txtPosition" size="5" value="1.0">
    秒播放:<input type="button" onclick="playposition();" value="确定">
</body>
</html>

2016/1/16音频播放器

标签:

原文地址:http://www.cnblogs.com/whatcanido/p/5135388.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!