[英]How to stream music in my app from Google Drive link and make the link accessible?
[英]How to get stream link from google drive
我想從Google驅動器獲取流鏈接而不在網絡瀏覽器上播放它。 格式鏈接是這樣的。 https://r6---sn-npo7zn7k.c.docs.google.com/videoplayback ..
這是驅動器鏈接演示: https : //drive.google.com/file/d/0B8_ZB_L8pVIkejU1ai1GNmhKa0k/view
您可以使用Drive REST API 。
在本教程的快速入門中,它將介紹如何在JavaScript中使用Drive Rest API,以及執行一些基本操作,例如打開Drive API,為OAuth創建客戶端ID等。
這是您將在快速入門中看到的示例代碼的一部分:
<html>
<head>
<script type="text/javascript">
// Your Client ID can be retrieved from your project in the Google
// Developer Console, https://console.developers.google.com
var CLIENT_ID = '<YOUR_CLIENT_ID>';
var SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly'];
/**
* Check if current user has authorized this application.
*/
function checkAuth() {
gapi.auth.authorize(
{
'client_id': CLIENT_ID,
'scope': SCOPES.join(' '),
'immediate': true
}, handleAuthResult);
}
然后,您將提取webViewLink
的值。
webViewLink
- 僅在公用文件夾上可用的鏈接,用於通過Google雲端硬盤的網站托管查看其靜態Web資產(HTML,CSS,JS等)。
這是一個示例響應 :
{
"kind": "drive#file",
"id": string,
"etag": etag,
"selfLink": string,
"webContentLink": string,
"webViewLink": string,
"alternateLink": string,
"embedLink": string,
"openWithLinks": {
(key): string
},
我希望這有幫助。
您可以從GetLinkDrive使用API:
例如: http://api.getlinkdrive.com/getlink?url=https://drive.google.com/file/d/0B6VYU2mjTdy0WVRjb1BJUU1hYXM/view
: http://api.getlinkdrive.com/getlink?url=https://drive.google.com/file/d/0B6VYU2mjTdy0WVRjb1BJUU1hYXM/view
url= http://api.getlinkdrive.com/getlink?url=https://drive.google.com/file/d/0B6VYU2mjTdy0WVRjb1BJUU1hYXM/view
: http://api.getlinkdrive.com/getlink?url=https://drive.google.com/file/d/0B6VYU2mjTdy0WVRjb1BJUU1hYXM/view
API將響應流鏈接如下:
[{"label":720,"type":"video/mp4","src":"https://redirector.googlevideo.com/videoplayback?requiressl=yes&id=19e3c7fd6fd45f15&itag=22&source=webdrive&ttl=transient&app=api.getlinkdrive.com&ip=139.162.5.123&ipbits=0&expire=1481719234&sparams=requiressl,id,itag,source,ttl,ip,ipbits,expire&signature=97E76D059F08E8B3B3C37FDE840C6B3978ACDD0C.8AF257B52254C7F116E658D6C52A3C5C3244EF75&key=ck2&mm=31&mn=sn-npoe7n7s&ms=au&mt=1481704609&mv=m&nh=IgpwcjA0LnNpbjExKgkxMjcuMC4wLjE&pl=22&safm=0&filename=video.mp4","file":"https://redirector.googlevideo.com/videoplayback?requiressl=yes&id=19e3c7fd6fd45f15&itag=22&source=webdrive&ttl=transient&app=api.getlinkdrive.com&ip=139.162.5.123&ipbits=0&expire=1481719234&sparams=requiressl,id,itag,source,ttl,ip,ipbits,expire&signature=97E76D059F08E8B3B3C37FDE840C6B3978ACDD0C.8AF257B52254C7F116E658D6C52A3C5C3244EF75&key=ck2&mm=31&mn=sn-npoe7n7s&ms=au&mt=1481704609&mv=m&nh=IgpwcjA0LnNpbjExKgkxMjcuMC4wLjE&pl=22&safm=0&filename=video.mp4","res":720}]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.