js控制优酷视频播放暂停

js控制优酷视频播放暂停

<!DOCTYPE html>  
<html>  
    <head>  
        <meta charset="utf-8">  
        <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">  
        <title>js控制优酷视频播放</title>  
        <script src="http://player.youku.com/jsapi"></script>  
        <script>  
            player = new YKU.Player("youkuplayer",{  
                styleid: "0",  
                client_id: "d8781b239fdad45b",  
                vid: "XMjg1MTcyNDQ0",  
                autoplay: false,  
                show_related: true,  
                events:{  
                    onPlayEnd: function(){ /*your code*/ },  
                    onPlayStart: function(){ /*your code*/ },  
                    onPlayerReady: function(){ /*your code*/ }  
                }  
            });  
            function playVideo(){  
                try{  
                    player.playVideo();  
                } catch(err){  
                    alert("*"+err);  
                }  
  
            }  
            function pauseVideo(){  
                player.pauseVideo();  
  
            }  
            function seekTo(s){  
                player.seekTo(s);  
            }  
            function currentTime(){  
                return player.currentTime();  
            }  
        </script>  
    </head>  
    <body>  
        <div id="youkuplayer" style="width:100%;height:400px;"></div>  
        <br />  
        <input type="button" onclick="playVideo();" value="播放" style="height:30px;width:50px;">  
        <input type="button" onclick="pauseVideo();" value="暂停" style="height:30px;width:50px;">  
    </body>  
</html>