同时使用壁画和MediaPlayer

时间:2019-03-10 06:00:00

标签: android android-mediaplayer

我正在使用Fresco库播放webp动画,并且我想同时使用android MediaPlayer播放声音,但是声音无法播放,我尝试在新的Thread nut中播放声音,但效果不佳:

Uri uri = new Uri.Builder()
                        .scheme(UriUtil.LOCAL_RESOURCE_SCHEME)
                        .path(String.valueOf(R.drawable.onestaranimation))
                        .build();


                DraweeController controller =
                Fresco.newDraweeControllerBuilder()
                        .setUri(uri)
                        .setAutoPlayAnimations(true)
                        .build();
                missionEndAnimationOneStar.setVisibility(View.VISIBLE);
                missionEndAnimationOneStar.setController(controller);
                playSound(R.raw.onestarsound);


    private void playSound(int sound){

            MediaPlayer mp = MediaPlayer.create(getApplicationContext(), sound);
            mp.start();
        }

我该怎么办?

1 个答案:

答案 0 :(得分:0)

您可能考虑使用AnimatedWebPDrawable来呈现动画,它似乎与MediaPlayer兼容。