MediaPlayer.setDataSource(String) not working with local files

前端 未结 6 1034
一个人的身影
一个人的身影 2020-12-02 20:31

I am able to play a local mp3 if I use the static method MediaPlayer.create(context, id) but it\'s not working if I use the non-static method MediaPlayer.setDataSource(Strin

6条回答
  •  离开以前
    2020-12-02 21:02

    Below code working for me i think this code will help you

        player = MediaPlayer.create(this,R.raw.test0);
        player.setLooping(true); // Set looping
    
        player.setVolume(100,100);
        player.start();
    
    @Override
    protected void onDestroy() {
    // TODO Auto-generated method stub
    super.onDestroy();
    player.stop();
    player.release();
    }
    

提交回复
热议问题