Support for initial skip chapters

This commit is contained in:
Kelvin 2023-12-20 00:28:21 +01:00
parent a4422fdd56
commit ee0bc96e53
6 changed files with 21 additions and 5 deletions

View File

@ -37,7 +37,8 @@ let Type = {
NORMAL: 0, NORMAL: 0,
SKIPPABLE: 5, SKIPPABLE: 5,
SKIP: 6 SKIP: 6,
SKIPONCE: 7
} }
}; };

View File

@ -14,7 +14,8 @@ enum class ChapterType(val value: Int) {
NORMAL(0), NORMAL(0),
SKIPPABLE(5), SKIPPABLE(5),
SKIP(6); SKIP(6),
SKIPONCE(7);

View File

@ -469,7 +469,7 @@ class VideoDetailView : ConstraintLayout {
if(!isScrub) { if(!isScrub) {
if(chapter?.type == ChapterType.SKIPPABLE) { if(chapter?.type == ChapterType.SKIPPABLE) {
_layoutSkip.visibility = VISIBLE; _layoutSkip.visibility = VISIBLE;
} else if(chapter?.type == ChapterType.SKIP) { } else if(chapter?.type == ChapterType.SKIP || chapter?.type == ChapterType.SKIPONCE) {
val ad = StateCasting.instance.activeDevice val ad = StateCasting.instance.activeDevice
if (ad != null) { if (ad != null) {
ad.seekVideo(chapter.timeEnd) ad.seekVideo(chapter.timeEnd)

View File

@ -27,6 +27,7 @@ import androidx.media3.ui.TimeBar
import com.futo.platformplayer.R import com.futo.platformplayer.R
import com.futo.platformplayer.Settings import com.futo.platformplayer.Settings
import com.futo.platformplayer.UIDialogs import com.futo.platformplayer.UIDialogs
import com.futo.platformplayer.api.media.models.chapters.ChapterType
import com.futo.platformplayer.api.media.models.chapters.IChapter import com.futo.platformplayer.api.media.models.chapters.IChapter
import com.futo.platformplayer.api.media.models.streams.sources.IAudioSource import com.futo.platformplayer.api.media.models.streams.sources.IAudioSource
import com.futo.platformplayer.api.media.models.streams.sources.IVideoSource import com.futo.platformplayer.api.media.models.streams.sources.IVideoSource
@ -471,6 +472,10 @@ class FutoVideoPlayer : FutoVideoPlayerBase {
_control_chapter_fullscreen.text = ""; _control_chapter_fullscreen.text = "";
} }
onChapterChanged.emit(currentChapter, isScrub); onChapterChanged.emit(currentChapter, isScrub);
val chapt = _currentChapter;
if(chapt?.type == ChapterType.SKIPONCE)
ignoreChapter(chapt);
} }
return true; return true;
} }

View File

@ -72,6 +72,7 @@ abstract class FutoVideoPlayerBase : RelativeLayout {
private val _referenceObject = Object(); private val _referenceObject = Object();
private var _connectivityLossTime_ms: Long? = null private var _connectivityLossTime_ms: Long? = null
private var _ignoredChapters: ArrayList<IChapter> = arrayListOf();
private var _chapters: List<IChapter>? = null; private var _chapters: List<IChapter>? = null;
var exoPlayer: PlayerManager? = null var exoPlayer: PlayerManager? = null
@ -273,13 +274,21 @@ abstract class FutoVideoPlayerBase : RelativeLayout {
} }
fun setChapters(chapters: List<IChapter>?) { fun setChapters(chapters: List<IChapter>?) {
_ignoredChapters = arrayListOf();
_chapters = chapters; _chapters = chapters;
} }
fun getChapters(): List<IChapter> { fun getChapters(): List<IChapter> {
return _chapters?.let { it.toList() } ?: listOf(); return _chapters?.let { it.toList() } ?: listOf();
} }
fun ignoreChapter(chapter: IChapter) {
synchronized(_ignoredChapters) {
if(!_ignoredChapters.contains(chapter))
_ignoredChapters.add(chapter);
}
}
fun getCurrentChapter(pos: Long): IChapter? { fun getCurrentChapter(pos: Long): IChapter? {
return _chapters?.let { chaps -> chaps.find { pos.toDouble() / 1000 > it.timeStart && pos.toDouble() / 1000 < it.timeEnd } }; val toIgnore = synchronized(_ignoredChapters){ _ignoredChapters.toList() };
return _chapters?.let { chaps -> chaps.find { pos.toDouble() / 1000 > it.timeStart && pos.toDouble() / 1000 < it.timeEnd && (toIgnore.isEmpty() || !toIgnore.contains(it)) } };
} }
fun setSource(videoSource: IVideoSource?, audioSource: IAudioSource? = null, play: Boolean = false, keepSubtitles: Boolean = false) { fun setSource(videoSource: IVideoSource?, audioSource: IAudioSource? = null, play: Boolean = false, keepSubtitles: Boolean = false) {

@ -1 +1 @@
Subproject commit d41cc8e848891ef8e949e6d49384b754e7c305c7 Subproject commit 13551ab67fc8fb1899b5bcbfdec750855b154790