diff --git a/android/app/src/main/java/top/ourfor/app/iplayx/view/player/Player.java b/android/app/src/main/java/top/ourfor/app/iplayx/view/player/Player.java index eeb05184..ff4032a7 100644 --- a/android/app/src/main/java/top/ourfor/app/iplayx/view/player/Player.java +++ b/android/app/src/main/java/top/ourfor/app/iplayx/view/player/Player.java @@ -35,6 +35,8 @@ default void loadSubtitle(List subtitles) {} default String currentAudioId() { return "no"; } default void setSubtitleFontName(String subtitleFontName) {} default void setSubtitleFontDirectory(String directory) {} + default void setSubtitleDelay(double delay) {} + default void setSubtitlePosition(double position) {} default void destroy() {} void useSubtitle(String id); diff --git a/android/app/src/main/java/top/ourfor/app/iplayx/view/video/MPVPlayerViewModel.java b/android/app/src/main/java/top/ourfor/app/iplayx/view/video/MPVPlayerViewModel.java index 988c02aa..ef1134ca 100644 --- a/android/app/src/main/java/top/ourfor/app/iplayx/view/video/MPVPlayerViewModel.java +++ b/android/app/src/main/java/top/ourfor/app/iplayx/view/video/MPVPlayerViewModel.java @@ -337,6 +337,18 @@ public void seekRelative(int seconds) { mpv.command("seek", String.valueOf(seconds), "relative+exact"); } + @Override + public void setSubtitleDelay(double delay) { + if (mpv == null) return; + mpv.setOptionString("sub-delay", String.valueOf(delay)); + } + + @Override + public void setSubtitlePosition(double position) { + if (mpv == null) return; + mpv.setOptionString("sub-pos", String.valueOf(position)); + } + @Override public void destroy() { if (mpv == null) return; diff --git a/android/app/src/main/java/top/ourfor/app/iplayx/view/video/PlayerAdvanceConfigView.java b/android/app/src/main/java/top/ourfor/app/iplayx/view/video/PlayerAdvanceConfigView.java new file mode 100644 index 00000000..9b5c16c9 --- /dev/null +++ b/android/app/src/main/java/top/ourfor/app/iplayx/view/video/PlayerAdvanceConfigView.java @@ -0,0 +1,70 @@ +package top.ourfor.app.iplayx.view.video; + +import android.content.Context; +import android.text.Editable; +import android.text.TextWatcher; +import android.view.LayoutInflater; + +import androidx.annotation.NonNull; +import androidx.constraintlayout.widget.ConstraintLayout; + +import top.ourfor.app.iplayx.databinding.PlayerAdvanceConfigBinding; +import top.ourfor.app.iplayx.view.player.Player; + +public class PlayerAdvanceConfigView extends ConstraintLayout { + PlayerAdvanceConfigBinding binding; + Player player; + + public PlayerAdvanceConfigView(@NonNull Context context) { + super(context); + binding = PlayerAdvanceConfigBinding.inflate(LayoutInflater.from(context), this, true); + setup(); + bind(); + } + + void setup() { + + } + + void bind() { + binding.subDelay.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void afterTextChanged(Editable editable) { + if (player != null) { + double delay = Double.parseDouble(editable.toString()); + player.setSubtitleDelay(delay); + } + } + }); + + binding.subPos.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void afterTextChanged(Editable editable) { + if (player != null) { + double position = Double.parseDouble(editable.toString()); + player.setSubtitlePosition(position); + } + } + }); + } +} diff --git a/android/app/src/main/java/top/ourfor/app/iplayx/view/video/PlayerControlView.java b/android/app/src/main/java/top/ourfor/app/iplayx/view/video/PlayerControlView.java index d8f50654..f9e5a068 100644 --- a/android/app/src/main/java/top/ourfor/app/iplayx/view/video/PlayerControlView.java +++ b/android/app/src/main/java/top/ourfor/app/iplayx/view/video/PlayerControlView.java @@ -53,6 +53,7 @@ public class PlayerControlView extends ConstraintLayout implements PlayerEventLi public PlayerControlItemView orientationButton; public PlayerControlItemView speedButton; public PlayerControlItemView commentButton; + public PlayerControlItemView advanceConfigButton; public TextView timeLabel; public TextView titleLabel; public PlayerSlider progressBar; @@ -133,6 +134,7 @@ private void setupUI() { orientationButton = binding.orientation; speedButton = binding.speed; commentButton = binding.comment; + advanceConfigButton = binding.advanceConfig; updatePlayerSlider(); } @@ -184,6 +186,7 @@ public void onStopTrackingTouch(SeekBar seekBar) { }); popup.show(); }); + binding.advanceConfig.setOnClickListener(v -> delegate.onAdvanceConfig()); binding.pipEnter.setOnClickListener(v -> delegate.onPipEnter()); binding.playlist.setOnClickListener(v -> delegate.onTapPlaylist()); binding.comment.setOnClickListener(v -> delegate.onTapComment()); diff --git a/android/app/src/main/java/top/ourfor/app/iplayx/view/video/PlayerEventListener.java b/android/app/src/main/java/top/ourfor/app/iplayx/view/video/PlayerEventListener.java index 4f91ca46..a39754ed 100644 --- a/android/app/src/main/java/top/ourfor/app/iplayx/view/video/PlayerEventListener.java +++ b/android/app/src/main/java/top/ourfor/app/iplayx/view/video/PlayerEventListener.java @@ -12,4 +12,5 @@ default void onTapPlaylist() {} default void onTapComment() {} default void onOrientationChange() {}; + default void onAdvanceConfig() {} } diff --git a/android/app/src/main/java/top/ourfor/app/iplayx/view/video/PlayerView.java b/android/app/src/main/java/top/ourfor/app/iplayx/view/video/PlayerView.java index fc12abb8..90c561d9 100644 --- a/android/app/src/main/java/top/ourfor/app/iplayx/view/video/PlayerView.java +++ b/android/app/src/main/java/top/ourfor/app/iplayx/view/video/PlayerView.java @@ -8,16 +8,19 @@ import android.animation.ObjectAnimator; import android.app.Activity; +import android.app.Dialog; import android.content.Context; import android.content.pm.ActivityInfo; import android.content.res.AssetManager; import android.graphics.Color; import android.media.AudioManager; import android.os.Build; +import android.util.Size; import android.view.KeyEvent; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; +import android.widget.Button; import android.widget.ImageView; import androidx.annotation.NonNull; @@ -212,7 +215,8 @@ void setupUI(Context context, String url) throws IOException { controlView.pipButton, controlView.playlistButton, controlView.orientationButton, - controlView.speedButton + controlView.speedButton, + controlView.advanceConfigButton ); eventView.delegate = this; eventView.trackSelectDelegate = this; @@ -408,6 +412,24 @@ public void onPipEnter() { XGET(Activity.class).enterPictureInPictureMode(); } + @Override + public void onAdvanceConfig() { + var dialog = new Dialog(getContext()); + var contentView = new PlayerAdvanceConfigView(getContext()); + contentView.player = this.controlView.player; + dialog.setContentView(contentView); + Window window = dialog.getWindow(); + if (window != null) { + Size size = DeviceUtil.screenSize(getContext()); + WindowManager.LayoutParams dialogLayoutParams = new WindowManager.LayoutParams(); + dialogLayoutParams.copyFrom(window.getAttributes()); + dialogLayoutParams.width = (int) (size.getWidth() * 0.5); + dialogLayoutParams.height = (int) (size.getHeight() * 0.8); + window.setAttributes(dialogLayoutParams); + } + dialog.show(); + } + @Override public void onSelectSubtitle() { var player = contentView.viewModel; diff --git a/android/app/src/main/res/layout/player_advance_config.xml b/android/app/src/main/res/layout/player_advance_config.xml new file mode 100644 index 00000000..1e1962de --- /dev/null +++ b/android/app/src/main/res/layout/player_advance_config.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/layout/player_control.xml b/android/app/src/main/res/layout/player_control.xml index 4cfd7c5b..ae01c7a3 100644 --- a/android/app/src/main/res/layout/player_control.xml +++ b/android/app/src/main/res/layout/player_control.xml @@ -88,6 +88,19 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" /> + + 视频源 音频源 字幕源 + 调整字幕延时 + 字幕显示位置偏移 + 对于部分播放器实现,某些配置可能无效 \ No newline at end of file diff --git a/android/app/src/main/res/values-television-night/strings.xml b/android/app/src/main/res/values-television-night/strings.xml index 06e3575a..fb02cc13 100644 --- a/android/app/src/main/res/values-television-night/strings.xml +++ b/android/app/src/main/res/values-television-night/strings.xml @@ -85,4 +85,7 @@ 视频源 音频源 字幕源 + 调整字幕延时 + 字幕显示位置偏移 + 对于部分播放器实现,某些配置可能无效 \ No newline at end of file diff --git a/android/app/src/main/res/values-television/strings.xml b/android/app/src/main/res/values-television/strings.xml index 06e3575a..fb02cc13 100644 --- a/android/app/src/main/res/values-television/strings.xml +++ b/android/app/src/main/res/values-television/strings.xml @@ -85,4 +85,7 @@ 视频源 音频源 字幕源 + 调整字幕延时 + 字幕显示位置偏移 + 对于部分播放器实现,某些配置可能无效 \ No newline at end of file diff --git a/android/app/src/main/res/values-zh/strings.xml b/android/app/src/main/res/values-zh/strings.xml index f66e108d..cf21952d 100644 --- a/android/app/src/main/res/values-zh/strings.xml +++ b/android/app/src/main/res/values-zh/strings.xml @@ -140,4 +140,7 @@ 视频源 音频源 字幕源 + 调整字幕延时 + 字幕显示位置偏移 + 对于部分播放器实现,某些配置可能无效 \ No newline at end of file diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 68e2482c..5f98a7ef 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -140,4 +140,7 @@ 视频源 音频源 字幕源 + 调整字幕延时 + 字幕显示位置偏移 + 对于部分播放器实现,某些配置可能无效 \ No newline at end of file