优酷接口的使用

1、定义上传视频jsp

<%@ page language=”java” import=”java.util.*” pageEncoding=”utf-8″ isELIgnored=”false”%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + “://”
+ request.getServerName() + “:” + request.getServerPort()
+ path + “/”;
%>
<!DOCTYPE html>
<html>
<head>
<base href=”<%=basePath%>” />
<meta charset=”utf-8″>
<title>达内·求职秀–求职秀-视频上传</title>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<meta name=”description” content=””>
<meta name=”author” content=””>
<link href=”http://open.youku.com/assets/lib/bootstrap2.1.0/css/bootstrap.css” rel=”stylesheet”>
<link href=”http://open.youku.com/assets/lib/bootstrap2.1.0/css/bootstrap-responsive.css” rel=”stylesheet”>

<style>
.uploadfile{width:150px;height: 14px;vertical-align: top;}
</style>
<script src=”http://open.youku.com/assets/lib/jquery-1.8.1.min.js”></script>
<script src=”http://open.youku.com/assets/lib/uploadjs.php”></script>
<script>
var USE_STREAM_UPLOAD = true;
jQuery(document).ready(function(){
//newWindow新弹出窗口方式
var param = {client_id:”3f55944758a967be”,
access_token:”feb81d9c7eff2b440d302770a4f389d5″,
oauth_opentype:”newWindow”,
oauth_redirect_uri:”<%=basePath%>user/jobSoo/oauth_result_newwindow.html”,
oauth_state:””,
completeCallback:”uploadComplete”,
categoryCallback:”categoryLoaded”};
//判断视频格式
$(“#fileInput”).live(‘change’,function(){
var fileName =  $(this).val();
//wmv,avi,dat,asf,rm,rmvb,ram,mpg,mpeg,3gp,mov,mp4,m4v,dvix,dv,dat,mkv,flv,vob,qt,divx,cpk,fli,flc,mod
if( !fileName.match(/.wmv|.avi|.dat|.asf|.rm|.rmvb|.ram|.mpg|.mpeg|.3gp|.mov|.mp4|.m4v|.dvix|.dv|.dat|.mkv|.flv|.vob|.qt|.divx|.cpk|.fli|.flc|.mod/i)){
alert(“视频格式格式或大小无效,最大支持上传1 GB, 视频文件允许上传的视频格式为:wmv,avi,dat,asf,rm,rmvb,ram,mpg,mpeg,3gp,mov,mp4,m4v,dvix,dv,dat,mkv,flv,vob,ram,qt,divx,cpk,fli,flc,mod。”);
//中断不了视频的提交事件
// return;
$(this).val(“”);
$(“#input01”).val(“”);
$(“#input02”).val(“”);
$(“#textarea”).val(“”);
}
checkDric();
checkTitle();
checkTags();
});

youkuUploadInit(param);
//将信息清空
$(“#textarea”).val(“”);
$(“#input01”).val(“”);
$(“#input02”).val(“”);

//重写取消上传的按钮的事件
var obj = $(“#btn-upload-stop”);
obj.removeAttr(“live”);
obj.live(‘click’,function (){
//$(this) //就是点击那那个button
return;
});
var obj2 = $(“#btn-upload-start”);
obj2.removeAttr(“live”);
obj2.live(‘click’,function (){
checkTitle();
checkTags();
checkDric();

});
});
//上传完成时回调方法
function uploadComplete(data){
var url =window.location.href;
url = url.substring(url.indexOf(“=”)+1);
window.location.href=”<%=basePath%>jobSoo/uploadVideo?videoId=” + data.videoid+”&videoTitle=”+data.title+”&jobSooId=”+url ;
}
//分类加载后回调方法
function categoryLoaded(data){
if(data.categories) {
var tpl = ”;
for (var i=0; i<data.categories.length; i++) {
if(data.categories[i].term == ‘Ads’){
tpl += ‘<option value=”‘ + data.categories[i].term + ‘” selected>’ + data.categories[i].label + ‘</option>’;
}else{
tpl += ‘<option value=”‘ + data.categories[i].term + ‘” >’ + data.categories[i].label + ‘</option>’;
}
}
$(“#category-node”).html(tpl);
}
}
/**
*检测标题
*/
function checkTitle(){
//显示数据
$(“#title_error_span”).hide();
$(“#title_right_span”).hide();
//获取昵称
var title = $(“#input01”).val();
//判断用户名是否为空
if(title == “” || title == null){
$(“#title_right_span”).hide();
$(“#title_error_span”).show();
}else if(title.length>30){
$(“#title_error_text”).text(“标题最多能输入30个字”);
$(“#title_right_span”).hide();
$(“#title_error_span”).show();
}else{
$(“#title_error_span”).hide();
$(“#title_right_span”).show();
}
}

发表评论

电子邮件地址不会被公开。 必填项已用*标注