• html文件播放MP4文件的源代码


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>无标题页</title>

        <script language="javascript"> 
    var state; 
    var varb; 
    var varfullscreen=0; 

    function loop() 

                WindowsMediaPlayer.playCount=2; 


    function openfile() 

                var fstr=''; 
                FileBtn.click(); 
                if (FileBtn.value=='') 
                return; 
                WindowsMediaPlayer.URL=FileBtn.value; 
                playerinfo1.innerHTML = '全声道 '; 
                playerinfo3.innerHTML="<b><font color=green>当前播放文件的路径和名称是: </font></b>"+FileBtn.value; 


    function playerinit() 

                WindowsMediaPlayer.url="unit10.wmv";             //定义你自己的文件 
                WindowsMediaPlayer.settings.autoStart = false ; 


    function play() 

                //if(WindowsMediaPlayer.URL='')alert('请打开文件');return; onload="playerinit()" 
                if (WindowsMediaPlayer.controls.isavailable('play')) 
                { 
                            WindowsMediaPlayer.controls.play(); 
                            state=setInterval("updatetime()",1000); 
                            playerinfo.innerHTML = "播放" 
                            varfullscreen=1; 
                            playerinfo2.innerHTML = '音量:'+WindowsMediaPlayer.settings.volume; 
                } 


    function voldown() 

                if ( WindowsMediaPlayer.settings.volume < 5 ) 
                { 
                            WindowsMediaPlayer.settings.volume = 0; 
                            playerinfo2.innerHTML = "音量:0"; 
                            playerinfo1.innerHTML = '沉默中 '; 
                } 
                else 
                { 
                            WindowsMediaPlayer.settings.volume -= 5; 
                            playerinfo2.innerHTML = '音量:'+WindowsMediaPlayer.settings.volume; 
                            playerinfo1.innerHTML = '非静音 '; 
                } 


    function volup() 

                if ( WindowsMediaPlayer.settings.volume > 95 ) 
                { 
                            WindowsMediaPlayer.settings.volume = 100; 
                            playerinfo2.innerHTML = "音量:100"; 
                            playerinfo1.innerHTML = '最大音 '; 
                } 
                else 
                { 
                            WindowsMediaPlayer.settings.volume += 5; 
                            playerinfo2.innerHTML = '音量:'+WindowsMediaPlayer.settings.volume; 
                            playerinfo1.innerHTML = '非静音 '; 
                } 


    function pause() 

                if (WindowsMediaPlayer.controls.isavailable('pause')) 
                { 
                            WindowsMediaPlayer.controls.pause(); 
                            clearInterval(state); 
                            playerinfo.innerHTML = "暂停"; 
                            varfullscreen=1; 
                } 


    function stop() 

                if (WindowsMediaPlayer.controls.isavailable('stop')) 
                { 
                            WindowsMediaPlayer.controls.stop(); 
                            clearInterval(state); 
                            playerinfo.innerHTML = "停止" 
                            varfullscreen=0; 
                } 


    function mute() 

                WindowsMediaPlayer.settings.mute = !WindowsMediaPlayer.settings.mute; 
                if(varb!=1) 
                { 
                            playerinfo1.innerHTML = '静音中 '; 
                            document.all.volup.disabled=true; 
                            document.all.voldown.disabled=true; 
                            document.all.balance.disabled=true; 
                            varb=1; 
                } 
                else 
                { 
                            playerinfo1.innerHTML = '非静音 '; 
                            document.all.volup.disabled=false; 
                            document.all.voldown.disabled=false; 
                            document.all.balance.disabled=false; 
                            varb=0; 
                } 


    function balance() 

                switch (WindowsMediaPlayer.settings.balance) 
                { 
                case 0: 
                            WindowsMediaPlayer.settings.balance = 100; 
                            playerinfo1.innerHTML = '左声道 '; 
                            break; 
                case 100: 
                            WindowsMediaPlayer.settings.balance = -100; 
                            playerinfo1.innerHTML = '右声道 '; 
                            break; 
                case -100: 
                            WindowsMediaPlayer.settings.balance = 0; 
                            playerinfo1.innerHTML = '全声道 '; 
                            break; 
                default : 
                            WindowsMediaPlayer.settings.balance = 0; 
                            playerinfo1.innerHTML = '全声道 '; 
                            break; 
                } 


    function fullScreen() 

                if(varfullscreen) 
                            WindowsMediaPlayer.fullScreen='true'; 
                else 
                            WindowsMediaPlayer.fullScreen='0'; 



    function updatetime() 

                if(WindowsMediaPlayer.controls.currentPositionString=='') 
                            { 
                                        playerinfo.innerHTML = "00:00" + " / " + WindowsMediaPlayer.currentMedia.durationString; 
                                        varfullscreen=0; 
                            } 
                else 
                            playerinfo.innerHTML = WindowsMediaPlayer.controls.currentPositionString + " / " + WindowsMediaPlayer.currentMedia.durationString; 

        </script>

        <script language="JavaScript" for="WindowsMediaPlayer" event="playstatechange(newstate)"> 
    switch (newstate) 

                case 1: 
                            playerinfo.innerHTML = "停止"; 
                            break; 
                case 2: 
                            playerinfo.innerHTML = "暂停"; 
                            break; 
                case 3: 
                            playerinfo.innerHTML = "正在播放"; 
                            break; 
                case 4: 
                            playerinfo.innerHTML = "4"; 
                            break; 
                case 5: 
                            playerinfo.innerHTML = "5"; 
                            break; 
                case 6: 
                            playerinfo.innerHTML = "正在缓冲..."; 
                            break; 
                case 7: 
                            playerinfo.innerHTML = "7"; 
                            break; 
                case 8: 
                            playerinfo.innerHTML = "8"; 
                            break; 
                case 9: 
                            playerinfo.innerHTML = "正在连接..."; 
                            break; 
                case 10: 
                            playerinfo.innerHTML = "准备就绪"; 
                            break; 
                case 11: 
                            playerinfo.innerHTML = "11"; 
                            break; 
                default: 
                            playerinfo.innerHTML = ""; 

        </script>

    </head>
    <body>
        <table width="100%" border="0" cellpadding="0" cellspacing="0" id="table1">
            <tr>
                <td colspan="2" align="center">
                    <object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="WindowsMediaPlayer"
                        width="400" height="300">
                        <param name="URL" value="F:1.mp4">
                    </object>
                </td>
            </tr>
            <tr>
                <td height="20" colspan="2" align="center">
                    <font color="red"><span id="playerinfo3"></span></font>
                </td>
            </tr>
            <tr>
                <td width="60%" height="20">
                    <input type="file" id="FileBtn" style="visibility: hidden">
                    <span id="playerinfo1"></span><font color="blue"><span id="playerinfo2"></span></font>
                </td>
                <td width="40%" height="20">
                    <span id="playerinfo"></span>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <input type="button" name="openfile" title="打开文件" onclick="openfile()" value="打开文件">
                    <input type="button" name="play" title="播放" onclick="play();" value="播放">
                    <input type="button" name="pause" title="暂停" onclick="pause();" value="暂停">
                    <input type="button" name="stop" title="停止" onclick="stop();" value="停止">
                    <input type="button" name="voldown" title="音量-" onclick="voldown();" value="音量-">
                    <input type="button" name="volup" title="音量+" onclick="volup();" value="音量+">
                    <input type="button" name="mute" title="静音?" onclick="mute();" value="静音?">
                    <input type="button" name="balance" title="声道" onclick="balance();" value="声道">
                    <input type="button" title="刷新" onclick="location.reload();" value="刷新">
                    <input type="button" title="全屏" value="全屏" onclick="fullScreen();">
                </td>
            </tr>
        </table>
    </body>
    </html>

    只有想不到,没有做不到!!!
    鸿鹄IT网络学院
  • 相关阅读:
    Java调用R环境配置问题:Cannot find JRI native library!
    在odoo 10.0配置文件中修改ip地址
    WordPress国外开源主题Enigma h1、h2、h3……标题不显示的解决办法
    ubuntu下编译为知笔记
    ubuntu linux 使用什么下载工具
    通过修改qt设置,解决LINK : fatal error LNK1104: 无法打开文件“kernel32.lib”
    [DONE]ReferenceError: WebSocket is not defined pomelo
    [DONE]pomelo npm-install 出现 AttributeError: 'module' object has no attribute 'script_main'
    finished running <my app>” on the targeted device
    c++中64位int与字符串的转换
  • 原文地址:https://www.cnblogs.com/zhongbin/p/3210098.html
Copyright © 2020-2023  润新知