- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
NOTE: I'm not working at the company where I worked when I posted this question, therefore, even though some great answers might comein, I won't actually be testing them since I don't have a reason to(other than promoting the community; which might cause me to do it oneday).
If however, some answer to the problem is promoted by many othercomunity members, I might opt to select it as the correct answer forthe problem experienced so many years after I originally posted thequestion.
In the meantime, I hope some of the answers may help some of you alsoexperiencing this problem. Yay for Stack Overflow!
我们的应用程序必须从在线来源流式传输音乐(我无权透露该来源)。
为什么在 S3 上开始流式传输需要 2 多分钟?
我发现 Media Player 对象由于 MEDIA_ERROR_UNKOWN 而进入 错误状态 - 太好了。对我帮助不大。因此,在使用 OnErrorListener 处理 onError 时,我重置了媒体播放器对象,然后调用 startPlaying 来完成其余的工作 - 设置数据源等。
成员:
private ProgressBar playSeekBar;
private ImageView ivPlay;
private ImageView ivPause;
private ImageView ivBuffer;
private MediaPlayer mPlayer;
private ImageView ivInfo;
private AudioManager audio;
初始化媒体播放器(和 Visualizer - 这不是本问题的问题)
private void initialMediaPlayerAndVisualizer() {
Log.d(TAG, "Initial Media Player and Visualizer");
playSeekBar = (ProgressBar) findViewById(R.id.progressBar1);
playSeekBar.setMax(100);
playSeekBar.setVisibility(View.GONE);
mPlayer = new MediaPlayer();
Log.d(TAG, "Create onErrorListener");
MediaPlayer.OnErrorListener errorListener = new MediaPlayer.OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
Log.d(TAG, "OnError - Error code: "+what+" Extra code: "+extra);
switch(what){
case -1004:
Log.d("Streaming Media", "MEDIA_ERROR_IO");
break;
case -1007:
Log.d("Streaming Media", "MEDIA_ERROR_MALFORMED");
break;
case 200:
Log.d("Streaming Media", "MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK");
break;
case 100:
Log.d("Streaming Media", "MEDIA_ERROR_SERVER_DIED");
break;
case -110:
Log.d("Streaming Media", "MEDIA_ERROR_TIMED_OUT");
break;
case 1:
Log.d("Streaming Media", "MEDIA_ERROR_UNKNOWN");
break;
case -1010:
Log.d("Streaming Media", "MEDIA_ERROR_UNSUPPORTED");
break;
}
switch(extra){
case 800:
Log.d("Streaming Media", "MEDIA_INFO_BAD_INTERLEAVING");
break;
case 702:
Log.d("Streaming Media", "MEDIA_INFO_BUFFERING_END");
break;
case 701:
Log.d("Streaming Media", "MEDIA_INFO_METADATA_UPDATE");
break;
case 802:
Log.d("Streaming Media", "MEDIA_INFO_METADATA_UPDATE");
break;
case 801:
Log.d("Streaming Media", "MEDIA_INFO_NOT_SEEKABLE");
break;
case 1:
Log.d("Streaming Media", "MEDIA_INFO_UNKNOWN");
break;
case 3:
Log.d("Streaming Media", "MEDIA_INFO_VIDEO_RENDERING_START");
break;
case 700 :
Log.d("Streaming Media", "MEDIA_INFO_VIDEO_TRACK_LAGGING");
break;
}
Log.d("Streaming Media", "Reset media player");
mPlayer.reset();
// We need to link the visualizer view to the media player so that it displays something
mVisualizerManager = new VisualizerManager(context); //(VisualizerView) findViewById(R.id.visualizerView);
//Send the visualizerContainer to the Renderer
visualizerRenderer = new VisualizerRenderer(arrayVisualizer);
mVisualizerManager.addRenderer(visualizerRenderer);
try {
startPlaying();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}
};
Log.d(TAG, "Set error listener on Media Player object");
mPlayer.setOnErrorListener(errorListener);
// We need to link the visualizer view to the media player so that it displays something
mVisualizerManager = new VisualizerManager(context); //(VisualizerView) findViewById(R.id.visualizerView);
//Send the visualizerContainer to the Renderer
visualizerRenderer = new VisualizerRenderer(arrayVisualizer);
mVisualizerManager.addRenderer(visualizerRenderer);
try {
startPlaying();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
开始播放:
private void startPlaying () throws IllegalStateException, IOException, UnsupportedOperationException
{
if(mPlayer != null){
ivPause.setVisibility(View.INVISIBLE);
ivPlay.setVisibility(View.INVISIBLE);
ivBuffer.setVisibility(View.VISIBLE);
mVisualizerManager.link(mPlayer);
mPlayer.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {
public void onBufferingUpdate(MediaPlayer mp, int percent) {
playSeekBar.setSecondaryProgress(percent);
Log.i("Buffering", "" + percent);
}
});
try {
mPlayer.setDataSource(theSource);
} catch (IllegalArgumentException e) {
Log.d(TAG, "Illegal Argument Exception: "+e);
e.printStackTrace();
} catch (IllegalStateException e) {
Log.d(TAG, "Illegal State Exception: "+e);
e.printStackTrace();
} catch (IOException e) {
Log.d(TAG, "IO Exception: "+e);
e.printStackTrace();
}
mPlayer.prepareAsync();
mPlayer.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
ivBuffer.setVisibility(View.INVISIBLE);
bars.setVisibility(View.INVISIBLE);
visualizerContainer.setVisibility(View.VISIBLE);
ivInfo.setImageResource(R.drawable.img_radio_info_online);
ivPause.setVisibility(View.VISIBLE);
ivPlay.setVisibility(View.INVISIBLE);
//Mute the video if the phone is muted.
if ((audio.getRingerMode() == AudioManager.RINGER_MODE_SILENT) || (audio.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE)) {
mp.setVolume(0, 0);
Toast toast = Toast.makeText(context, R.string.device_muted, Toast.LENGTH_LONG);
toast.show();
}
mPlayer.start();
}
});
}else{
Log.d(TAG, "Media player is null.");
initialMediaPlayerAndVisualizer();
}
}
停止播放:
private void stopPlaying()
{
bars.setVisibility(View.VISIBLE);
visualizerContainer.setVisibility(View.INVISIBLE);
ivInfo.setImageResource(R.drawable.img_radio_info_offline);
ivPlay.setVisibility(View.VISIBLE);
ivPause.setVisibility(View.INVISIBLE);
mPlayer.stop();
mVisualizerManager.release();
mPlayer.release();
mPlayer = null;
}
一点日志:
05-21 16:26:23.600: I/Buffering(3921): 0
05-21 16:26:23.600: I/MediaPlayer(3921): Info (703,156)
05-21 16:26:23.600: I/MediaPlayer(3921): Info (701,0)
05-21 16:26:23.610: D/VisualizerRenderer(3921): Render columns
05-21 16:26:23.715: V/MediaPlayer(3921): message received msg=100, ext1=1, ext2=-110
05-21 16:26:23.715: E/MediaPlayer(3921): error (1, -110)
05-21 16:26:23.715: V/MediaPlayer(3921): callback application
05-21 16:26:23.715: V/MediaPlayer(3921): back from callback
05-21 16:26:23.725: D/VisualizerRenderer(3921): Render columns
05-21 16:26:23.725: E/MediaPlayer(3921): Error (1,-110)
05-21 16:26:23.725: D/MAIN(3921): OnError - Error code: 1 Extra code: -110
05-21 16:26:23.725: D/Streaming Media(3921): MEDIA_ERROR_UNKNOWN
05-21 16:26:23.725: D/Streaming Media(3921): Reset media player
05-21 16:26:23.725: V/MediaPlayer-JNI(3921): reset
05-21 16:26:23.725: V/MediaPlayer(3921): reset
05-21 16:26:23.730: D/VisualizerRenderer(3921): Divisions: 9
05-21 16:26:23.730: D/VisualizerManager(3921): Added te renderer
05-21 16:26:23.730: V/MediaPlayer-JNI(3921): get_session_id()
05-21 16:26:23.735: D/VisualizerManager(3921): Media player and visualizer linked
05-21 16:26:23.735: D/VisualizerManager(3921): Set capture listener
05-21 16:26:23.735: D/VisualizerManager(3921): Set on visualizer complete listener
05-21 16:26:23.740: V/MediaPlayer(3921): setVideoSurfaceTexture
05-21 16:26:23.740: V/MediaPlayer(3921): prepareAsync
05-21 16:26:25.285: V/MediaPlayer(3921): message received msg=3, ext1=0, ext2=0
05-21 16:26:25.285: V/MediaPlayer(3921): buffering 0
05-21 16:26:25.285: V/MediaPlayer(3921): callback application
05-21 16:26:25.285: V/MediaPlayer(3921): back from callback
05-21 16:26:25.330: I/Buffering(3921): 0
05-21 16:26:25.390: V/MediaPlayer(3921): message received msg=3, ext1=0, ext2=0
05-21 16:26:25.390: V/MediaPlayer(3921): buffering 0
05-21 16:26:25.390: V/MediaPlayer(3921): callback application
05-21 16:26:25.390: V/MediaPlayer(3921): back from callback
05-21 16:26:25.425: I/Buffering(3921): 0
05-21 16:26:25.490: V/MediaPlayer(3921): message received msg=3, ext1=0, ext2=0
05-21 16:26:25.490: V/MediaPlayer(3921): buffering 0
05-21 16:26:25.490: V/MediaPlayer(3921): callback application
05-21 16:26:25.490: V/MediaPlayer(3921): back from callback
...
05-21 16:26:52.585: I/Buffering(3921): 0
05-21 16:26:53.570: V/MediaPlayer(3921): message received msg=3, ext1=0, ext2=0
05-21 16:26:53.570: V/MediaPlayer(3921): buffering 0
05-21 16:26:53.570: V/MediaPlayer(3921): callback application
05-21 16:26:53.570: V/MediaPlayer(3921): back from callback
05-21 16:26:53.585: I/Buffering(3921): 0
05-21 16:26:54.570: V/MediaPlayer(3921): message received msg=3, ext1=0, ext2=0
05-21 16:26:54.570: V/MediaPlayer(3921): buffering 0
05-21 16:26:54.570: V/MediaPlayer(3921): callback application
05-21 16:26:54.570: V/MediaPlayer(3921): back from callback
05-21 16:26:54.570: V/MediaPlayer(3921): message received msg=200, ext1=702, ext2=0
05-21 16:26:54.570: W/MediaPlayer(3921): info/warning (702, 0)
05-21 16:26:54.570: V/MediaPlayer(3921): callback application
05-21 16:26:54.570: V/MediaPlayer(3921): back from callback
05-21 16:26:54.590: I/Buffering(3921): 0
05-21 16:26:54.590: I/MediaPlayer(3921): Info (702,0)
05-21 16:26:55.575: V/MediaPlayer(3921): message received msg=3, ext1=0, ext2=0
05-21 16:26:55.575: V/MediaPlayer(3921): buffering 0
05-21 16:26:55.575: V/MediaPlayer(3921): callback application
05-21 16:26:55.575: V/MediaPlayer(3921): back from callback
05-21 16:26:55.575: I/Buffering(3921): 0
05-21 16:26:56.575: V/MediaPlayer(3921): message received msg=3, ext1=0, ext2=0
05-21 16:26:56.575: V/MediaPlayer(3921): buffering 0
05-21 16:26:56.575: V/MediaPlayer(3921): callback application
05-21 16:26:56.575: V/MediaPlayer(3921): back from callback
05-21 16:26:56.585: I/Buffering(3921): 0
05-21 16:26:57.575: V/MediaPlayer(3921): message received msg=3, ext1=0, ext2=0
05-21 16:26:57.575: V/MediaPlayer(3921): buffering 0
05-21 16:26:57.575: V/MediaPlayer(3921): callback application
05-21 16:26:57.575: V/MediaPlayer(3921): back from callback
05-21 16:26:57.600: I/Buffering(3921): 0
05-21 16:26:57.930: V/MediaPlayer-JNI(3921): stop
05-21 16:26:57.930: V/MediaPlayer(3921): stop
05-21 16:26:57.930: D/VisualizerManager(3921): Released the visualizer
05-21 16:26:57.930: V/MediaPlayer-JNI(3921): release
05-21 16:26:57.930: V/MediaPlayer(3921): setListener
05-21 16:26:57.930: V/MediaPlayer(3921): disconnect
05-21 16:26:57.935: V/MediaPlayer(3921): destructor
05-21 16:26:57.935: V/MediaPlayer(3921): disconnect
最佳答案
这个问题的答案原来是安装在运行 Android 4.1.2 的三星 S III 设备上的 Android 固件问题。
这似乎与流的来源有关,因为某些来源最终在设备上播放,但我们需要的那个从未播放过。
如果您可以从其他来源获取流,它应该可以工作。
因此,如果您正在为特定公司/目的开发应用程序并且对流的源有一定的控制权,或者可以与控制流源的人进行通信,请让他们更改流的源流到可以在运行 Android 4.1.2 的三星 S III 上运行的东西。
除此之外,所有能解决这个问题的都是固件升级。
关于android - MediaPlayer 错误 (1, -1004) aka MEDIA_ERROR_IO 试图在三星 S3 上流式传输音乐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16672568/
这个问题在这里已经有了答案: Why don't Java's +=, -=, *=, /= compound assignment operators require casting? (11 个
我搜索了很多,但没有一个链接能帮助我解决这个问题。我得到了 ORA-21500: internal error code, arguments: [%s], [%s], [%s], [%s], [%s
我正在做 RegexOne 正则表达式教程,它有一个 question关于编写正则表达式以删除不必要的空格。 教程中提供的解决方案是 We can just skip all the starting
([\s\S]+|\s?) 中 |\s? 的目的或作用是什么?如果没有它,表达式会不会与 ([\s\S]+) 相同? 最佳答案 这不是完全相同的。 ([\s\S]+|\s?) 会匹配空字符串,而 ([
这个正则表达式有一组还是两组? 我正在尝试使用第二组访问 bookTitle 但出现错误: Pattern pattern = Pattern.compile("^\\s*(.*?)\\s+-\\s+
在 C 中给定一个字符串指针 s,下面的迭代会做什么?即它以什么方式遍历字符串? for (++s ; *s; ++s); 最佳答案 for (++s ; *s;++s) 表示 将指针 s 递增到字符
我正在用一个 node.js 应用程序解析一个大列表并有这段代码 sizeCode = dbfr.CN_DESC.split('\s+-\s*|\s*-\s+') 这似乎不起作用,因为它返回了 [ '
我正在编写一个简单的字符串连接程序。 该程序按照我发布的方式运行。但是,我首先使用以下代码编写它来查找字符串的结尾: while (*s++) ; 但是,这个方法并没有奏效。我传递给它的字符串
这个问题已经有答案了: What does (?和aramchand来自Mohandas Karamchand G 因此,在使用这些匹配来分割字符串后,您最终会得到 {"M", "K", "G"} 注
我正在尝试转换 Map到 List使用 lambda。 本质上,我想将键和值与 '=' 连接起来之间。这看起来微不足道,但我找不到如何去做。 例如 Map map = new HashMap<>();
我正在经历 K & R,并且在递增指针时遇到困难。练习 5.3(第 107 页)要求您使用指针编写一个 strcat 函数。 在伪代码中,该函数执行以下操作: 将 2 个字符串作为输入。 找到字符串
在下面的代码中,pS 和 s.pS 在最后一行是否保证相等?也就是说,在语句S s = S();中,是否可以确定不会构造一个临时的S? #include using namespace std; s
演示示例代码: public void ReverseString(char[] s) { for(int i = 0, j = s.Length-1; i < j; i++, j--){
我一直在寻找类似于 .NET examples 中的示例的 PowerShell 脚本.取一个 New-TimeSpan 并显示为 1 天 2 小时 3 分钟 4 秒。排除其零的地方,在需要的地方添加
def func(s): s = s + " is corrected" return s string_list = ["She", "He"] for s in string_li
我是 python 的新手。当我在互联网上搜索 lambda 时。我在 lambda_functions 中找到了这个声明. processFunc = collapse and (lambda s:
我最近开始学习正则表达式,并试图为上面的问题写一个正则表达式。如果限制只放在一个字母上(例如不超过 2 个“b”),这并不困难。 那么答案就是:a* c*(b|ε)a* c*(b|ε)a* c* 但是
当我运行 npm install 时出现以下错误,但我无法修复它。 我试过:npm install -g windows-build-tools 也没有修复这个错误 ERR! configure
有很多有趣的haskell网上可以找到片段。 This post可以在 this (awesome) Stack Overflow question 下找到. The author写道: discou
我知道以下三行代码旨在将字符串提取到$ value中并将其存储在$ header中。但是我不知道$value =~ s/^\s+//;和$value =~ s/\s+$//;之间有什么区别。 $val
我是一名优秀的程序员,十分优秀!