简体   繁体   English

Android 媒体播放器:如何通过 url 离线播放音频?

[英]Android Media Player: how to play audio offline by url?

In my app(using kotnlin ), i need to play some audios from url and they are can be big, like ~50mb, so the main thing is - i want to play this audios also offline if they are started listeting by user.在我的应用程序中(使用kotnlin ),我需要从 url 播放一些音频,它们可能很大,比如 ~50mb,所以主要是 - 如果用户开始播放这些音频,我想也离线播放这些音频。 In other words, if i press play - the audio start playing, but if I will turn off the internet after some time, I can still listen to the audio to the end, how can i do this using andoid-mediaPlayer?换句话说,如果我按播放 - 音频开始播放,但如果我在一段时间后关闭互联网,我仍然可以听完音频,我该如何使用 andoid-mediaPlayer 做到这一点?

As a variant you can download this file (use DownloadManager for example) in background and if the connection will be lost you should catch it and resume playing with the downloaded file.作为变体,您可以在后台下载此文件(例如使用 DownloadManager),如果连接丢失,您应该捕获它并继续播放下载的文件。 When playing finish just remove the file.播放完成后只需删除文件。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM