MediaPlayer的:应该已经设置副标题控制器:奇巧 [英] MediaPlayer : Should have subtitle controller already set: KitKat

查看:155
本文介绍了MediaPlayer的:应该已经设置副标题控制器:奇巧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题,在我的音频文件播放,有时,有时不玩了。美中不足的是,当它决定不打,DDMS给我的:

  E / MediaPlayer的:应该已经设置副标题控制器
 

由于这是一对一与音乐未播放,我已确定,这可能是问题...

如果音乐不打,我打的音量按钮,它开始播放。 如果我等到没打约30秒后,开始重新开始(不循环)。

请告诉我怎么回事?我在奇巧使用

 播放器=新的MediaPlayer();
        AssetFileDescriptor AFD = NULL;
        尝试 {
            AFD = getAssets()openFd(Theme.mp3)。
        }赶上(IOException异常E){
            e.printStackTrace();
        }
        尝试 {
            player.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength());
        }赶上(IOException异常E){
            e.printStackTrace();
        }
        尝试 {
            播放器prepare()。
        }赶上(IOException异常E){
            e.printStackTrace();
        }
        player.setLooping(真正的); //重新达到播放结束
        //player.setVolume(1,1); //设置左,右卷。范围是从0.0到1.0
        player.start(); //开始回放
 

解决方案

看着一个<一个href="http://stackoverflow.com/questions/20087804/should-have-subtitle-controller-already-set-mediaplayer-error-android">$p$pvious讨论的计算器,并且引用的<一个href="https://android.googlesource.com/platform/frameworks/base/+/bbf4962%5E%5E1..bbf4962%5E/">Android提交其中,这是介绍,code以上可能无法完全初始化的MediaPlayer 对象。

借助奇巧例如code 媒体播放暗示你应该叫

mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);

您构建的MediaPlayer 之后,你调用它的的setDataSource 方法之前。

I am having an odd issue where my audio file sometimes plays and sometimes does not play. The catch is that when it decides to not play, the DDMS gives me an:

E/MediaPlayer﹕ Should have subtitle controller already set

Because this is one-to-one with the music not playing, I have determined that this is probably the issue...

If the music is not playing and I hit the volume button it begins to play. If I wait about 30 seconds of no-play, it begins to start again (not looping).

Whats going on here? I am on KitKat using

        player = new MediaPlayer();
        AssetFileDescriptor afd = null;
        try {
            afd = getAssets().openFd("Theme.mp3");
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            player.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength()); 
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            player.prepare();
        } catch (IOException e) {
            e.printStackTrace();
        }
        player.setLooping(true); //restart playback end reached
        //player.setVolume(1, 1); //Set left and right volumes. Range is from 0.0 to 1.0
        player.start(); //start play back

解决方案

Looking at a previous discussion on StackOverflow, and the referenced Android commit where this was introduced, the code above might not completely initialize the MediaPlayer object.

The KitKat example code for media playback suggests that you should call:

mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);

immediately after you construct the MediaPlayer, and before you call its setDataSource method.

这篇关于MediaPlayer的:应该已经设置副标题控制器:奇巧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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