如何使用媒体播放器设置对象。我想在 OnCompletionListener 中获取的那个对象

MediaPlayer mp = new MediaPlayer();
       //mp.set("data"); // i wonna put string data
        mp.setDataSource(sound);
        } catch (Exception e) {
        e.printStackTrace();
        }
        mp.setOnCompletionListener(completelistner);
        OnCompletionListener completelistner = new OnCompletionListener() {

    @Override
    public void onCompletion(MediaPlayer mp) {
         //mp.get("data");

    }
};

最佳答案

让它像这样:

public class YourClass {

private MediaPlayr mp; // now it is a global variable


mp = new MediaPlayer();


}

编辑:根据 Google documentation , MediaPlayer (mp) 没有任何 mp.set(String) 或 mp.get(String) 方法。

关于android - 在 OnCompletionListener 中使用 MediaPlayer get 添加对象,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28167302/

10-12 00:38
查看更多