Sometimes, in the work of some customers need to use video, we all know that video is very cost-consuming, so if the project requires customers to buy a video server alone is very out of the box. Then upload the video to Youku, Iqiyi and other video sites to host that is a good solution.
Today, we are mainly talking about the MP4 format URL address that you can use to dynamically get your own uploaded video using Iqiyi open platform. We talk less and start straight.
First look at the video playback effect obtained in this way:
first, we need to register as a iqiyi developer
Iqiyi Open Platform: http://open.iqiyi.com/index.html
Second, after the registration audit passed, we entered the video hosting
Build your own hosted application:http://open.iqiyi.com/lib/upload.html
Iii. learning documents, making interface calls
Four, the package code is as follows
1<! DOCTYPE html>234<meta charset= "UTF-8" >5<title> get Iqiyi Art upload video MP4 format URL address </title>6<script src= "Http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js" ></script>7<style>8 . main{9width:40%;Ten margin:200px Auto; One } A</style> - -<body> the -<div class= "Main" > -<video id= "SetUrl" width= "550" height= "310" Controls type= "Video/mp4" preload= "None" poster= "Bg.png" ></video > -</div> + -<script type= "Text/javascript" > +$(function(){ A //------------------------test Data-------------------------- at varFile_id= "3856cf8b9e34492db5faa827d9a0c663";//File Upload ID - //------------------------test Data-------------------------- - //get MP4 format URL - GetURL (file_id,function (URL) { - console.log (URL); - $ ("#setUrl"). attr ("src", url); in }); - to //encapsulate get MP4 format URL function + functionGetURL (file_id,callback) { - varapp_key= ' xxxxxxxxxxxxxxxxxxxxxx ';//App_key assigned when applying for application the varapp_secret= ' xxxxxxxxxxxxxxxxxxxxxxxxx ';//App_secret assigned when applying for application * //Get access token $ $.ajax ({Panax NotoginsengType: "GET", -URL: "https://openapi.iqiyi.com/api/iqiyi/authorize?client_id=" +app_key+ "&client_secret=" +app_secret+ "", theData: "", +DataType: "JSON", ASuccessfunction(e) { the varGetObject =Json.parse (e); + //var Access_token=getobject.data.access_token;//Open platform assigned access Token,oauth authorized to get "under official circumstances" - //------------------------test Data-------------------------- $ varAccess_token= "2.65f2da58f8c9d91eb7da125b317c9193";//open Platform assigned access Token,oauth authorized to get "test data" $ //------------------------test Data-------------------------- - //get a list of video URLs - $.ajax ({ theType: "GET", -URL: "http://openapi.iqiyi.com/api/file/urllist?access_token=" +access_token+ "&file_id=" +file_id+ "",WuyiData: "", theDataType: "JSON", -Successfunction(data) { Wu varGetData =json.parse (data); - vargeturllink= (getdata.data.mp4[1]);//get the URL request you need About //get the video URL in MP4 format $ $.ajax (Geturllink, { -Data: "", -DataType: ' Jsonp ',//Address for cross-domain issues here -Crossdomain:true, ASuccessfunction(data) { + varVideourl =Data.data.l; the Callback.call (this,videourl); //callback Gets the URL of the MP4 format - }, $Error:function() { theConsole.log ("Request to get video URL for mp4 format failed"); the } the }); the - }, inError:function() { theConsole.log ("Request to get video URL list failed"); the } About }); the the }, theError:function() { +Console.log ("Request for access token failed"); - } the });Bayi } the }); the</script> -</body> -Dynamic acquisition of Iqiyi art upload video MP4 format URL address