[英]Using Android's MediaPlayer class, play an audio file (google drive/drop box/zoho docs)
I have an app on google play store that displays a book content. 我在谷歌游戏商店有一个应用程序,显示书籍内容。 I am trying to embed audio feature for the app.
我正在尝试为应用程序嵌入音频功能。 But the audio files would increase the size of the app drastically.
但是音频文件会大大增加应用程序的大小。
So, I am thinking to store the audio files in Google Drive / Drop Box or Zoho Docs and use Media Player class to stream and play the audio file. 所以,我想将音频文件存储在Google Drive / Drop Box或Zoho Docs中,并使用Media Player类来传输和播放音频文件。 But it does not work.
但它不起作用。 It throws FileNotFound Exception.
它抛出FileNotFound Exception。 Is there any way to achieve this?
有没有办法实现这个目标?
mPlayer = new MediaPlayer();
mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
if (mbAudioOn)
{
try
{
if (mPlayer != null && mPlayer.isPlaying())
{
mPlayer.stop();
}
mPlayer.setDataSource("https://www.dropbox.com/s/avvy670dxc76y80/audio_02.m4a");
mPlayer.prepare();
mPlayer.start();
}
catch (Exception e)
{
e.printStackTrace();
}
}
I think this used to be doable in Google Drive before when hosting was still supported by Google Drive. 我认为以前在谷歌云端硬盘驱动器仍然支持托管之前,这在Google云端硬盘中是可行的。 This SO thread shares a way to do that.
这个SO线程共享一种方法。 However, in Google's blog post , web hosting is now deprecated, August 21, 2016 being the official date.
但是,在Google的博客文章中 ,虚拟主机现已弃用,2016年8月21日为正式日期。 So Google Drive is no longer the option for this.
因此Google云端硬盘不再是此选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.