开发者

Copying Media Player Object

开发者 https://www.devze.com 2023-02-28 18:36 出处:网络
If I create a copy of a MediaPlayer object, which object will a callback function be 开发者_如何转开发called on.For example:

If I create a copy of a MediaPlayer object, which object will a callback function be 开发者_如何转开发called on. For example:

MediaPlayer mp = new MediaPlayer();
MediaPlayer mp_copy = mp;

mp.setOnBufferingUpdateListener(...);
mp_copy.setOnBufferingUpdateListener(...);

When the buffer is updated, which object will receive the callback (or will both of them)?

Thanks.


When you do this:

MediaPlayer mp_copy = mp;

you are not making a copy of a MediaPlayer object. You are making a new reference to the same object. The second call to setOnBufferingUpdateListener will undo the effect of the first call.

0

精彩评论

暂无评论...
验证码 换一张
取 消