一、抓取遠程視頻文件
首選需要一個非本地視頻,一個視頻鏈接,例如本例的視頻:http://112.90.246.23/plvod01.videocc.net/sl8da4jjbx/2/sl8da4jjbx692db9d494a9986ab8c7a2.mp4
然后通過writetoken,執行API的uploadUrlFile方法,即可把視頻直接上傳到視頻云端,并返回視頻信息。
二、代碼
視頻文件鏈接: <input type="text" id="fileUrl" value="http://112.90.246.23/plvod01.videocc.net/sl8da4jjbx/2/sl8da4jjbx692db9d494a9986ab8c7a2.mp4" size="100">
writetoken: <input type="text" id="writetoken" value="Y07Q4yopIVXN83n-MPoIlirBKmrMPJu0" size="40">
<input type="button" id="button" value="點擊抓取">
標題 <input id="title" size="70">
首圖 <input id="first_image" size="70"><img src="" id="first_image_img" style="display:none">
播放鏈接 <input id="swf_link" size="70">
<script>
$("#button").click(function(){
$("#button").val("正在抓取,請稍后");
$.get("http://v.polyv.net/uc/services/rest", {
method:"uploadUrlFile",
fileName:"remotefile title",
writetoken:$("#writetoken").val(),
fileUrl:$("#fileUrl").val()
},function(video){
$("#button").val("抓取完成");
$("#title").val(video.data[0].title);
$("#first_image").val(video.data[0].first_image);
$("#first_image_img").attr("src",video.data[0].first_image);
$("#first_image_img").css({display:"block"});
$("#swf_link").val(video.data[0].swf_link);
});
});
</script>
三、運行實例
請點擊:上傳遠程視頻
請點擊:上傳遠程視頻