优酷网页player使用-替换视频ID即可

一个页面中只有一个播放器

如http://player.youku.com/embed/XMTMwODg5OTcyMA

查看源代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title>Youku Universal Player</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style>
        html, body { height:100%; }
        body { margin:0; }
    </style>
</head>
<body>
<div id="youku-playerBox" style="width:100%;height:100%;"></div>
<script id='_youkujs_' type="text/javascript"></script>
<script language="javascript">
    // var wh = { };
    window.onload = function(){
        /*wh = function () {
         var dimension = {};
         dimension.width = window.innerWidth;
         dimension.height = window.innerHeight;
         //console.log(dimension);
         return dimension;

         }();*/

        <!-- 这个页面是直接内嵌的,第三方用户不需要管 -->
        <!-- 目前不支持starttime等动作参数 -->
        var script = document.getElementById('_youkujs_');
        script.src = 'http://player.youku.com/jsapi';
        script.onload = script.onreadystatechange = function(){

            if(!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete'){
                var _QS = QS();
               <span style="color:#cccccc;"> /*QS.width = QS.width ? QS.width : wh.width;
                 QS.height = QS.height ? QS.height :wh.height;*/
                var arr = window.location.pathname.split('/');
                if(arr.length == 3 && arr[1] == 'embed' && arr[2].charAt(0) == 'X' ){
                    _QS.vid = arr[2];//这里只是对优酷地址的验证
                }</span>
		<span style="color:#ff0000;">		</span><u><span style="color:#ff0000;">_QS.vid = </span><span style="color:#ff6666;"><span style="background-color: rgb(255, 255, 255);">"</span><span style="background-color: rgb(255, 255, 255);">XNzAxMzExMzU2</span><span style="background-color: rgb(255, 255, 255);">"</span>;替换此ID即可</span></u>
                if(_QS.target == null ) _QS.target = "youku-playerBox";
                if(_QS.client_id == null) _QS.client_id = "0edbfd2e4fc91b72";//"youkuind_";
                var _select = new YoukuPlayerSelect(_QS);
                _select.select();
            }
        };
    };
</script>
</body>
</html>
代码中引用的优酷jsapi,并对页面地址进行了判断,保证是优酷地址,提取出视频id

我们要播放优酷视频直接替换红字部分的id即可(可在视频播放页面地址中获取)

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值