1

我使用 MediaOnCompletionListener 来释放对象,所以它相当重要。但是,正如您从下面的 logcat 片段中看到的那样,它并不总是被触发!

12-30 17:24:41.448: I/myApp(5117): playSound(/mnt/sdcard/audio/clong-1.mp3 VolumePercent:100)
12-30 17:24:41.638: I/myApp(5117): playSound(/mnt/sdcard/audio/clong-1.mp3 VolumePercent:100)
12-30 17:24:41.818: I/myApp(5117): playSound(/mnt/sdcard/audio/clong-1.mp3 VolumePercent:100)
12-30 17:24:49.866: I/myApp(5117): MediaOnCompletionListener triggered
12-30 17:24:50.136: I/myApp(5117): MediaOnCompletionListener triggered
12-30 17:24:50.186: I/myApp(5117): MediaOnCompletionListener triggered
12-30 17:24:55.902: I/myApp(5117): playSound(/mnt/sdcard/audio/clong-1.mp3 VolumePercent:100)
12-30 17:24:56.152: I/myApp(5117): playSound(/mnt/sdcard/audio/clong-1.mp3 VolumePercent:100)
12-30 17:24:56.322: I/myApp(5117): playSound(/mnt/sdcard/audio/clong-1.mp3 VolumePercent:100)
12-30 17:24:56.552: I/myApp(5117): playSound(/mnt/sdcard/audio/clong-1.mp3 VolumePercent:100)
12-30 17:25:04.340: I/myApp(5117): MediaOnCompletionListener triggered
12-30 17:25:04.560: I/myApp(5117): MediaOnCompletionListener triggered
12-30 17:25:04.670: I/myApp(5117): MediaOnCompletionListener triggered
12-30 17:25:04.910: I/myApp(5117): MediaOnCompletionListener triggered
12-30 17:25:37.312: I/myApp(5117): playSound(/mnt/sdcard/audio/clong-1.mp3 VolumePercent:100)
12-30 17:25:37.592: I/myApp(5117): playSound(/mnt/sdcard/audio/clong-1.mp3 VolumePercent:100)
12-30 17:25:37.773: I/myApp(5117): playSound(/mnt/sdcard/audio/clong-1.mp3 VolumePercent:100)
12-30 17:25:37.953: I/myApp(5117): playSound(/mnt/sdcard/audio/clong-1.mp3 VolumePercent:100)
12-30 17:25:46.161: I/myApp(5117): MediaOnCompletionListener triggered
12-30 17:25:46.351: I/myApp(5117): MediaOnCompletionListener triggered
12-30 17:26:09.423: I/myApp(5117): playSound(/mnt/sdcard/audio/clong-1.mp3 VolumePercent:100)
12-30 17:26:35.108: I/myApp(5117): playSound(/mnt/sdcard/audio/clong-1.mp3 VolumePercent:100)
12-30 17:26:42.215: I/myApp(5117): playSound(/mnt/sdcard/audio/clong-1.mp3 VolumePercent:100)
12-30 17:26:50.594: I/myApp(5117): MediaOnCompletionListener triggered
12-30 17:27:17.059: I/myApp(5117): playSound(/mnt/sdcard/audio/clong-1.mp3 VolumePercent:100)
12-30 17:27:25.448: I/myApp(5117): MediaOnCompletionListener triggered

我正在 Android 2.3.5 上测试这是一个已知问题吗?MediaPlayer 的可靠性是否在更高版本的 Android 上有所提高?

4

1 回答 1

0

不确定,但可能 是垃圾收集原因:MediaPlayer finalized without being released 将提供线索。

人们发现,在某些情况下,玩家在发布之前会被垃圾收集。也许,已经收集垃圾的玩家不会调用 onCompletionListener 。

于 2013-09-17T05:51:53.283 回答