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

寻技术 Html/CSS 2023年07月11日 114

<!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" >
            </td>
        </tr>
    </table>
</body>
</html>

关闭

用微信“扫一扫”