简体   繁体   English

流音频文件以在Android中使用Google Drive API从Google Drive播放

[英]stream audio files to play from google drive using google drive api in android

I have developed an android app using which one can upload,download,create files on Google Drive.Now I want to play audio files (not after downloading but streaming )which are on Google Drive in custom music player. 我开发了一个Android应用程序,可以在Google Drive上上传,下载,创建文件。现在,我想播放自定义音乐播放器中Google Drive上的音频文件(不是下载后而是流式播放)。 For playing audio files I'm using link provided in music file response such as 为了播放音频文件,我使用了音乐文件响应中提供的链接,例如

musicFile.getSelfLink()
musicFile.getAlternateLink()
musicFile.getSelfLink()
musicFile.getDefaultOpenWithLink()
musicFile.getWebContentLink()

I tried all links provided in response.But could not play music file.It gave me errors like 我尝试了所有提供的链接作为响应,但无法播放音乐文件,这给了我类似的错误

Couldn't open file on client side, trying server side or media player error 无法在客户端打开文件,尝试服务器端或媒体播放器错误

Please help me.Am I missing something? 请帮助我。我想念什么吗? Thanks in advance. 提前致谢。

Authorize the file.getDownloadLink() with your user's access token. 使用用户的访问令牌对file.getDownloadLink()进行授权。 You should be able to stream it. 您应该能够流式传输它。

When you need to play your private files, you need next link: 当需要播放私人文件时,需要下一个链接:

String link = file.getDownloadUrl() + "&access_token=" + yourToken + "&alt=media";

It works for me in REST API v2 在REST API v2中对我有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android Google Play / Drive Api - Android Google Play / Drive Api 使用 Google Drive Android API 从 Google Drive 下载图像? - Downloading Images from Google Drive using Google Drive Android API? 在Android中使用Google Drive API上传文件 - Uploading files using google drive api in android Google Drive Android API如何将音频文件上传到我的驱动器? 如何同步驱动器文件? - Google Drive Android API how to upload a audio file to my drive ? How to sync drive files? 无法使用Google Drive API Android从Google Drive查询“与我共享”的文件 - unable to query the files “shared with me” from google drive using Google drive api android 谷歌驱动器配额使用android api驱动器 - google drive quota using android api for drive 如何使用Google Drive Android API删除Google Drive上的文件 - How to delete a file on google drive using Google Drive Android API 在Android中以编程方式使用Google Drive API将图像上传到Google Drive - Upload image to a google drive using google drive api programatically in android 来自 Google Drive 的 Android Stream 视频 - Android Stream video from Google drive 在 Android Studio 中使用 Google Drive API 从驱动器下载文件以上传到另一个驱动器 - Download file from drive to upload into another drive using Google Drive API in Android Studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM