js操作流媒體視頻方法

來源:互聯網
上載者:User

<script>
        function show(ur, id) {

            var plaryer = document.getElementById("mediaplayer1")
            for (var i = 0; i < plaryer.currentPlaylist.count; i++) {
                // alert(plaryer.currentPlaylist.Item(i).getItemInfo("Title"));
                if (plaryer.currentPlaylist.Item(i).getItemInfo("Title") == id) { //根據div中vid與播放器title進行對應
                    plaryer.controls.playItem(plaryer.currentPlaylist.Item(i)); //指定播放第幾首
                    plaryer.controls.CurrentPosition = ur; //設定播放的時間
                }
            }

        }
        function pause() {
            var vID = document.getElementById("mediaplayer1").currentMedia.getItemInfo("Title");
            //            alert(s);
            var current_time = document.getElementById("MediaPlayer1").controls.currentPosition;
            var current_times = parseInt(current_time);
            var obj = window.top.frames['PPTSld'];
            var returns = obj.document.getElementsByName("showsd");
            if (returns.length > 0) return returns;
            returns = new Array();
            var e = obj.document.getElementsByTagName("div");

            var urls = obj.location.href; //擷取url中"?"符後的字串
            var url = "";
            var va = "";
            if (urls.indexOf("#") >= 0) {
                url = urls.substr(0, urls.indexOf("#"));
                va = urls.substr(urls.indexOf("#"), urls.length);
            } else {
                url = urls;
            }

            var j = 0;
            for (var i = 0; i < e.length; i++) {
                    if (e[i].getAttribute("name") == "showsd") {
                        if (e[i].className != "box2") {
                            e[i].className = "box2"; //回複樣式
                        }
                        if (e[i].getAttribute("vID") == vID) {
                            if (current_times >= e[i].getAttribute("timeflag")) {//判斷目前時間如果小於找到的ppt時間則現正播放該ppt
                                j = i;
                            }
                        }
                    }
               
                if (i + 1 == e.length) {
                    // alert(e[i].getAttribute("id"));
                    if (va == "") {
                        obj.location.href = url + "#" + e[j].getAttribute("id");
                    } else {
                        if (va != "#" + e[j].getAttribute("id")) {
                            //alert(va);
                            obj.location.href = url + "#" + e[j].getAttribute("id");
                           // alert(obj.location.href);
                        }
                    }

                    if (e[j].className != "") {
                        e[j].className = "box"//改變其樣式讓其現正播放
                    }
                }
            }
            setTimeout('pause()', 1000);
        }
        // alert(document.getElementById("mediaplayer1").GetMediaInfoString(9));
    </script>

</head>
<body onload="pause()">
    <form id="form1" runat="server">
    <div id="txt" style="color: #ff0000; font-weight: bold; font-size: 18px; font-family: arial">
        <object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="286" height="255"
            codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,

52,701" id="MediaPlayer1" type="application/x-oleobject" standby="Loading Microsoft&reg;Windows&reg; Media Player components...">
            <param name="AutoStart" value="-1" />
            <!--是否自動播放-->
            <param name="Balance" value="0" />
            <!--調整左右聲道平衡,同上面舊播放器代碼-->
            <param name="enabled" value="-1" />
            <!--播放器是否可人為控制-->
            <param name="EnableContextMenu" value="-1" />
            <!--是否啟用操作功能表-->
            <param name="url" value='<%=url %>' />
            <!--播放的檔案地址-->
            <param name="PlayCount" value="1000" />
            <!--播放次數控制,為整數-->
            <param name="rate" value="1" />
            <!--播放速率控制,1為正常,允許小數,1.0-2.0-->
            <param name="currentPosition" value="0" />
            <!--控制項設定:當前位置-->
            <param name="currentMarker" value="0" />
            <!--控制項設定:當前標記-->
            <param name="defaultFrame" value="" />
            <!--顯示預設架構-->
            <param name="invokeURLs" value="-1" />
            <!--指令碼命令設定:是否調用URL-->
            <param name="baseURL" value="" />
            <!--指令碼命令設定:被調用的URL-->
            <param name="stretchToFit" value="0" />
            <!--是否按比例伸展-->
            <param name="volume" value="50" />
            <!--預設聲音大小0%-100%,50則為50%-->
            <param name="mute" value="0" />
            <!--是否靜音-->
            <param name="uiMode" value="Full" />
            <!--播放器顯示模式:Full顯示全部;mini最簡化;None不顯示播放控制,只顯示視頻視窗;invisible全

部不顯示-->
            <param name="windowlessVideo" value="0" />
            <!--如果是0可以允許全屏,否則只能在視窗中查看-->
            <param name="fullScreen" value="0" />
            <!--開始播放是否自動全屏-->
            <param name="enableErrorDialogs" value="-1" />
            <!--是否啟用錯誤提示報告-->
            <param name="SAMIFilename" />
            <!--字幕ID-->
            <param name="DisplaySize" value="3" />
            <param name="ShowDisplay" value="1">
        </object>
        <div id="mu" runat="server">
        </div>
    </div>
    </form>
</body>
</html>

    <script>
        function goNote(pa) {
            var obj = window.top.frames['PPTOtl'];
            var vid = pa.vID;
           
            var plaryer = obj.document.getElementById("mediaplayer1");
            //alert(plaryer.currentPlaylist.Item(0));
            var titles = plaryer.currentMedia.getItemInfo("Title");
            //alert(plaryer.currentPlaylist.Item(1).getItemInfo("Title"));
            for (var i = 0; i < plaryer.currentPlaylist.count; i++) {
                // alert(plaryer.currentPlaylist.Item(i).getItemInfo("Title"));
                if (plaryer.currentPlaylist.Item(i).getItemInfo("Title") == vid) { //根據div中vid與播放器title進行對應
                    plaryer.controls.playItem(plaryer.currentPlaylist.Item(i)); //指定播放第幾首
                    plaryer.controls.CurrentPosition = pa.timeflag; 
                }
            }
           
        }
    </script>

asx播放清單:

if (!IsPostBack)
            {
                // string s = Request.ServerVariables["HTTP_REFERER"].ToString();
                //string s = Request.UrlReferrer.ToString();
                //Session["video"] != null
                if (Session["video"] != null)
                {

                    int vID = 0;
                    if (Request.QueryString["vID"] != null)
                    {
                        vID = int.Parse(Request.QueryString["vID"].ToString());
                    }
                    string sql = "select paths,pID from voidepathtb where vID=" + vID;
                    DataTable dt = DBHelper.GetDataTable(sql, CommandType.Text, null);
                    Response.Clear();
                    string Info = "<asx version=\"3.0\">";

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Info += "<entry><title>" + dt.Rows[i]["pID"].ToString() + "</title><ref href=" + "\"" + Server.UrlPathEncode(dt.Rows[i]["paths"].ToString()) + "\" /></entry>";
                    }
                    Info += "</asx>";
                    Response.Write(Info);
                    Session.Remove("video");
                    Response.End();

                }
            }

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.