zoukankan      html  css  js  c++  java
  • 【WAP触屏】YouKu视频弹窗播放组件

     

    (function(window){
    /*	
    	youku api : http://open.youku.com/tools
    
    	调用方法 : LM_youkuPop.open('XODI5Mzk3MDAw');
    */
    
    var head = document.getElementsByTagName('head')[0],
    	youkuApi = 'http://player.youku.com/jsapi',
    	cssTmpl = '#LM-youkuPop{display:none; z-index: 999; position: fixed;top:0;left:0; 100%;height: 100%;background: rgba(0,0,0,0.9);}'+
    			  '#LM-youkuPop-close{position: absolute;top:20px;right:20px; 30px;height: 30px;background-color: #fff;color: #000;text-align: center;line-height: 30px;font-size: 20px;-webkit-border-radius:99px;}'+
    			  '#LM-youkuPop-youkuPlayer{ 100%;height: auto; position: absolute;top:50%;left:0;-webkit-transform: translateY(-50%);}';
    
    var LM_youkuPop = {
    	init:function(){
    		this.creatScript(youkuApi).creatStyle(cssTmpl).creatPop().bindEvent();
    	},
    
    	open:function(vid){
    		this.vid = vid;
    		if(!this.script){this.init();}
    		if(!this.isScript){return this.loadScript();}
    
    		this.box.style.display = 'block';
    		player = new YKU.Player('LM-youkuPop-youkuPlayer',{
    	         'styleid': "0",
    	         'client_id': "d841b3f800b5ce4b",
    	         'vid': this.vid,
    	         'autoplay': true
    		});
    	},
    
    	isScript:false,
    
    	loadScript:function(){
    		var that = this;
    		this.script.onload = function() {
    			if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete" ) {
    				that.isScript = true;
    				that.open(that.vid);
    			}
    		}
    	},
    
    	close:function(){
    		this.box.style.display = 'none';
    		document.getElementById('LM-youkuPop-youkuPlayer').innerHTML = '';
    	},
    
    	bindEvent:function(){
    		var that = this;
    		document.getElementById('LM-youkuPop-close').onclick = function(){
    			that.close();
    		};
    		return this;
    	},
    
    	creatPop:function(){
    		var div=document.createElement('div');
    		div.id = 'LM-youkuPop';
    		div.innerHTML = '<div id="LM-youkuPop-close">X</div><div id="LM-youkuPop-youkuPlayer" style="100%;height:240px;"></div>';
    		document.body.appendChild(div);
    		this.box = div;
    		return this;
    	},
    
    	creatStyle :function (css){
    		var style=document.createElement('style');
    		style.innerHTML = css;
    		head.appendChild(style);
    		return this;
    	},
    
    	creatScript :function (url){
    		var script=document.createElement('script');
    		script.src = url;
    		head.appendChild(script);
    		this.script = script;
    		return this;
    	}
    	
    }
    
    
    window['LM_youkuPop'] = LM_youkuPop;
    
    })(window)
    

      

  • 相关阅读:
    转:阅读代码
    转:三个教程
    转:C/C++程序员简历模板
    转:对于一个字节(8bit)的变量,求其二进制表示中“1”的个数
    内存偏移
    转:用C++实现的一种插件体系结构-----概述
    转:用异或实现两个数的交换的问题
    转:二级指针
    转:《链接、装载与库》里的一个错误:关于调用栈
    转:你应当如何学习C++(以及编程)(rev#1)
  • 原文地址:https://www.cnblogs.com/dtdxrk/p/4597213.html
Copyright © 2011-2022 走看看