- <script>
- var liveUrl = 'https://pcs.baidu.com/rest/2.0/pcs/device?method=liveplay&shareid={$shareid}&uk={$uk}&type=hls';
- var poster = "http://pcs.baidu.com/rest/2.0/pcs/device?method=thumbnailurl&shareid={$shareid}&uk={$uk}";
- var _width = $(window).width();
- var _height = parseInt(_width*9/16);
- var _top_margin = parseInt(($(window).height() - _height)/3);
- $(".player").css({"width":_width,"height":_height,"margin-top":_top_margin});
- loadVideo();
- function loadVideo(){
- $.ajax({
- url:liveUrl,
- dataType:'jsonp',
- jsonpCallback:'jsonpCallback',
- success:function(data){
- var raw_id = /id\s=\s"[a-zA-Z\d]+"/.exec(data.div);
- var raw_src = /src\s=\s"[.:\/_a-zA-Z=\?\&\d]+"/.exec(data.div);
- if(raw_src[0].toLowerCase().indexOf('m3u8')==-1){
- loadVideo();
- return false;
- }
- var id = raw_id[0].slice(6,-1);
- var src = raw_src[0].slice(7,-1);
- $("video").prop({"id":id,"src":src,"poster":poster});
- init_player(_width,_height,id);
- /*$("video")[0].play();
- var playTimer = setInterval(function(){
- $("video")[0].paused?$("video")[0].play():clearInterval(playTimer);
- },50)*/
- $(".device-name,.header span").text(data.description);
- }
- })
- }
- function init_player(width,height,ele) {
- if(typeof(width) == "number" && typeof(height) == "number") {
- $("#"+ele).css({"width":width,"height":height});
- }
- }
- $(function(){
- var count = 0;
- /*检查是否在百度app中 www.bcty365.com*/
- if (isBdBox()) {
- if (isIphone()) {
- $(function () {
- checkBLightApp();
- });
- }
- }else{
- $(".header").show();
- $(".header-title-icon").css('top',function(){
- return parseInt(($(".header p").height()-46)/2);
- }()).click(function(){
- window.history.back();
- })
- }
- function isBdBox() {
- /* 判断userAgent是否包含baiduboxapp www.bcty365.com*/
- return navigator.userAgent.search(/baiduboxapp/) != -1;
- }
- function checkBLightApp() {
- count++;
- if (!hideTitlebar() && count < 80) {
- setTimeout(checkBLightApp, 40);
- }
- }
- function hideTitlebar() {
- if ((typeof BLightApp !== 'undefined')) {
- $(".header").hide();
- return true;
- }
- return false;
- }
- function isIphone() {
- return navigator.userAgent.search(/iPhone/) != -1;
- }
- });
- </script>