使用MediaPlayer添加对象获取OnCompletionListener

时间:2015-01-27 09:42:49

标签: android android-mediaplayer

如何使用媒体播放器设置对象。我希望进入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");

    }
};

1 个答案:

答案 0 :(得分:1)

像这样:

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)方法。