最新消息: 生命不止,奋斗不息……

CC视频JS接口

PHP php 734浏览 0评论

项目中遇到了调用第三方日志的需求,特记录下来。
实现功能:
1.点击目录,实现Ajax加载视频,不会重新刷新页面
2.当前视频播放完成,自动播放下一个视频
3.视频全屏
4.能够在任何一个时间点实现与客户端用户的交互

143088

<script>
$(document).ready(function(){
	$('.play').click(function(){
	var lessionId = $(this).attr('id');
	var lessionIds = $(this).next().attr('id');//获取下一个视频ID
	$('#lessionId').val(lessionIds);赋给隐藏域
	$.ajax({
	   type: "POST",
           url: "watch.php",
	   data: "action=playvideo&amp;lessionId="+lessionId,
	   success: function(msg){
	        jsonObj = $.parseJSON(msg)
	        var videoId = jsonObj.videoId;
		var companyId = jsonObj.companyId;
		var lessonId = jsonObj.lessionId;
		var swfobj=new SWFObject('http://union.bokecc.com/flash/player.swf', 'playerswf', '960', '505', '8');
		swfobj.addVariable( "userid" , companyId);	//partnerID,用户id
		swfobj.addVariable( "videoid" , videoId);	//spark_videoid,视频所拥有的 api id
		swfobj.addVariable( "playerid" , "1234567890");//播放器ID
		swfobj.addVariable( "htwxpara" , "{'\lessonid'\:"+lessonId+"}");
		swfobj.addVariable( "mode" , "api");	//mode, 注意:必须填写,否则无法播放
		swfobj.addVariable( "autostart" , "true");	//开始自动播放,true/false
		swfobj.addVariable( "jscontrol" , "true");	//	开启js控制播放器,true/false
		swfobj.addParam("allowFullscreen","true");
		swfobj.addParam("allowScriptAccess","always");
		swfobj.addParam("wmode","opaque");
		//swfobj.addParam('wmode','transparent');
		swfobj.write('swfDiv');//将播放器写入预留的id为swfDiv的div里
			}
		});
	     });
        })

//播放器开始播放时调用的函数
      function on_spark_player_start() {
	setTimeout("player_duration()",5000);
      }

//	功能:播放器暂停后,继续播放时所调用函数
	function on_spark_player_resume() {
	   setTimeout("player_duration()",900);
	}

//功能:播放器播放停止时所调用函数 (课后测试调用)
function on_spark_player_stop(){
	var lessionId = $('#lessionId').val();//当上一个视频停止后,自动调用了此方法,获得了下一个视频Id
	var lessionIds = $("#"+lessionId).next().attr('id');//获取下一个视频id
	$('#lessionId').val(lessionIds);//写入隐藏域
	$.ajax({
		 type: "POST",
		 url: "watch.php",
		data: "action=playvideo&amp;lessionId="+lessionId,
		success: function(msg){
		jsonObj = $.parseJSON(msg)
		var videoId = jsonObj.videoId;
		var companyId = jsonObj.companyId;
		var lessonId = jsonObj.lessionId;
		var swfobj=new SWFObject('http://union.bokecc.com/flash/player.swf', 'playerswf', '960', '505', '8');
		swfobj.addVariable( "userid" , companyId);	//partnerID,用户id
		swfobj.addVariable( "videoid" , videoId);	//spark_videoid,视频所拥有的 api id
		swfobj.addVariable( "playerid" , "1234567890");//播放器ID
                swfobj.addVariable( "htwxpara" , "{'\lessonid'\:"+lessonId+"}");
		swfobj.addVariable( "mode" , "api");	//	mode, 注意:必须填写,否则无法播放
		swfobj.addVariable( "autostart" , "true");	//	开始自动播放,true/false
		swfobj.addVariable( "jscontrol" , "true");	//	开启js控制播放器,true/false
		swfobj.addParam("allowFullscreen","true");
		swfobj.addParam("allowScriptAccess","always");
		swfobj.addParam("wmode","opaque");
		//swfobj.addParam('wmode','transparent');
		swfobj.write('swfDiv');
				}
			});
		}

		//功能: 加载完成后调用方法
		function on_spark_player_ready(){

		}

          function player_duration(){
		var total_timer = parseInt(document.getElementById("playerswf").spark_player_duration());//视频总时长
		var timer =  parseInt(document.getElementById("playerswf").spark_player_position());//当前播放时长
                 //其他自定义操作

	}
</script>
	<div id='swfDiv'>

	<div>
        <div>//这里是目录
          <li class='play' id="1">视频1</li>
          <li class='play' id="2">视频2</li>
        </div>

转载请注明:IT世界 » CC视频JS接口

您必须 登录 才能发表评论!