优酷视频控制

本文介绍如何使用JavaScript控制优酷视频的播放、暂停及跳转等功能。通过引入优酷的jsapi,开发者可以轻松实现视频播放器的基本交互操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<!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://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
    <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(){ },
                onPlayStart: function(){ },
                onPlayerReady: function(){ }
            }
        });
        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>

查看API请移步:http://doc.open.youku.com/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值