Android 4.4(API 19)上的MediaPlayer流问题 [英] MediaPlayer Streaming issues on Android 4.4 (API 19)

查看:192
本文介绍了Android 4.4(API 19)上的MediaPlayer流问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序在MediaPlayer流中存在问题,特别是在Nexus 5上.我不确定这是否是导致问题的Nexus 5或API 19级.基本上我的MediaPlayer已经准备好了,我打电话给MediaPlayer.start(),但是MediaPlayer并没有开始流式传输.

My app is having issues with the MediaPlayer streaming, specifically on Nexus 5. I'm not sure if this is Nexus 5 or API level 19 causing the problem. Basically my MediaPlayer gets prepared and I call MediaPlayer.start(), but the MediaPlayer doesn't begin streaming.

这是随机发生的,并且仅在我的Nexus 5设备上发生.发生这种情况时,如果我尝试寻找MediaPlayer,它将开始播放.还有其他人遇到这种情况吗?

This happens at random and only on my Nexus 5 device. When this happens, if I try seeking the MediaPlayer it begins to play. Is anyone else experiencing this?

更新:我已经针对Android提交了一个错误: https://code.google.com/p/android/issues/detail?id=62304

UPDATE: I've filed a bug against Android: https://code.google.com/p/android/issues/detail?id=62304

推荐答案

不确定是否相关,我在本地文件播放中遇到了类似的问题,仅在4.4上存在,在4.3上无法再现.仅当我想重用现有的MediaPlayer播放新歌曲时才会发生这种情况.

Not sure if it's related, I had similar issue with local file playback, only on 4.4 occasionally, not reproducible on 4.3. This only happens when I want to play a new song reusing the existing MediaPlayer.

解决方案:我不得不调用stop();在reset()之前;和setDataSource():

Solution: I had to call stop(); before reset(); and setDataSource():

    stop();
    reset();

    try {
        setDataSource(context, uri);
        prepareAsync();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

这篇关于Android 4.4(API 19)上的MediaPlayer流问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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