网络改变的Andr​​oid的MediaPlayer流站 [英] Android MediaPlayer streaming stops on network change

查看:117
本文介绍了网络改变的Andr​​oid的MediaPlayer流站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在流媒体使用的MediaPlayer在Android上的音频。

I am streaming audio using MediaPlayer on Android.

当从Wi-Fi设备移动到细胞网络,反之亦然,在MediaPlayer停止播放。

When the device moves from Wi-Fi to the cell network or vice-versa, the MediaPlayer stops playback.

典型地有几秒价值中的音频缓冲器,所以播放不会立即停止。

Typically there are a few seconds-worth of audio in the buffer, so playback does not cease immediately.

在理想情况下,我想拿起流不间断的播放,但我看不出如何做到这一点。

Ideally I would like to pick up the stream for uninterrupted playback, but I cannot see how to do it.

我正与托管服务器和现场广播流在两个MP3文件。

I am working with both mp3 files hosted on the server and a live broadcast stream.

推荐答案

从服务器的角度来看,改变网络模式从WiFi到3G(反之亦然),看起来就像从一个单独的IP的(客户端),一个全新的连接。

From a servers point of view, changing network mode from WiFi to 3G (visa versa), will look like a brand new connection from a separate IP's (client).

如果您是从下载的服务器不支持跟踪数据流(秒,序列号,例如,字节)(不像媒体服务器),这将不得不再次开始提供从0字节的MP3。

If the server that you are downloading from does not support tracking the stream (e.g number of seconds, sequence, byte) (unlike media-servers),It will have to start serving your mp3 from 0 byte again.

如果您的网址指向位于一个标准的HTTP服务器上的MP3文件,您的情况会会发生什么。你应该考虑使用一个媒体流服务器,所以你可以继续下载/在你选择的流。当您收到的意图,该连接丢失/恢复,您可以将您的媒体播放器到新的URL与URL中的文件位置(例如秒= 19字节= 57365)。

If your URL is pointing to a MP3 file located at a standard HTTP server, your situation will be what to expect. You should look into using a Media streaming server, so you could resume downloading/streaming at your choice. When you receive the intent that the connection is lost/resume, you could point your mediaplayer to the new URL with file-position in the URL (e.g seconds=19, bytes=57365).

不知道这是否可以帮助你,但它解释了一下怎么回事幕后。

Not sure if this helps you, but it explains a bit whats going on "behind the scenes".

这篇关于网络改变的Andr​​oid的MediaPlayer流站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆