diff --git a/app/src/main/java/cn/hugh/bz/gk2/wallpaper/VideoPlayer.java b/app/src/main/java/cn/hugh/bz/gk2/wallpaper/VideoPlayer.java index f1d7d61..a457c29 100644 --- a/app/src/main/java/cn/hugh/bz/gk2/wallpaper/VideoPlayer.java +++ b/app/src/main/java/cn/hugh/bz/gk2/wallpaper/VideoPlayer.java @@ -27,9 +27,9 @@ public class VideoPlayer { private FileLogger fileLogger; public interface VideoPlayerCallback { - void onPrepared(); - void onError(String error); - void onCompletion(); + void onPrepared(); // 视频准备完成 + void onError(String error); // 播放出错 + void onCompletion(); // 播放完成(现在会触发,因为不再循环) } public void setSurface(Surface surface) { @@ -68,7 +68,7 @@ public class VideoPlayer { throw e; } - mediaPlayer.setLooping(true); + mediaPlayer.setLooping(false); // 改为 false,播放完成后不循环 mediaPlayer.setVolume(volume, volume); mediaPlayer.setOnPreparedListener(mp -> { @@ -120,7 +120,8 @@ public class VideoPlayer { fileLogger.warn(TAG, "Ignoring onCompletion from stale MediaPlayer"); return; } - fileLogger.log(TAG, "Video completed"); + fileLogger.log(TAG, "Video playback completed"); + isPrepared = false; // 标记为未准备状态 if (callback != null) { callback.onCompletion(); }