Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment
import com.lagradost.cloudstream3.utils.AppContextUtils
import com.lagradost.cloudstream3.utils.AppContextUtils.requestLocalAudioFocus
import com.lagradost.cloudstream3.utils.DataStoreHelper
import com.lagradost.cloudstream3.utils.EpisodeSkip
import com.lagradost.cloudstream3.utils.UIHelper
import com.lagradost.cloudstream3.utils.UIHelper.hideSystemUI
import com.lagradost.cloudstream3.utils.UIHelper.popCurrentPage
import com.lagradost.cloudstream3.utils.videoskip.VideoSkipStamp
import java.net.SocketTimeoutException

enum class PlayerResize(@StringRes val nameRes: Int) {
Expand Down Expand Up @@ -127,11 +127,11 @@ abstract class AbstractPlayerFragment(
throw NotImplementedError()
}

open fun onTimestamp(timestamp: EpisodeSkip.SkipStamp?) {
open fun onTimestamp(timestamp: VideoSkipStamp?) {

}

open fun onTimestampSkipped(timestamp: EpisodeSkip.SkipStamp) {
open fun onTimestampSkipped(timestamp: VideoSkipStamp) {

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,13 @@ import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
import com.lagradost.cloudstream3.utils.Coroutines.runOnMainThread
import com.lagradost.cloudstream3.utils.DataStoreHelper.currentAccount
import com.lagradost.cloudstream3.utils.DrmExtractorLink
import com.lagradost.cloudstream3.utils.EpisodeSkip
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.ExtractorLinkPlayList
import com.lagradost.cloudstream3.utils.ExtractorLinkType
import com.lagradost.cloudstream3.utils.PLAYREADY_UUID
import com.lagradost.cloudstream3.utils.SubtitleHelper.fromTagToLanguageName
import com.lagradost.cloudstream3.utils.WIDEVINE_UUID
import io.github.anilbeesetti.nextlib.media3ext.ffdecoder.NextRenderersFactory
import com.lagradost.cloudstream3.utils.videoskip.VideoSkipStamp
import kotlinx.coroutines.delay
import okhttp3.Interceptor
import org.chromium.net.CronetEngine
Expand Down Expand Up @@ -884,10 +883,10 @@ class CS3IPlayer : IPlayer {
private var currentTextRenderer: TextRenderer? = null
}

private fun getCurrentTimestamp(writePosition: Long? = null): EpisodeSkip.SkipStamp? {
private fun getCurrentTimestamp(writePosition: Long? = null): VideoSkipStamp? {
val position = writePosition ?: this@CS3IPlayer.getPosition() ?: return null
for (lastTimeStamp in lastTimeStamps) {
if (lastTimeStamp.startMs <= position && (position + (toleranceBeforeUs / 1000L) + 1) < lastTimeStamp.endMs) {
if (lastTimeStamp.timestamp.startMs <= position && (position + (toleranceBeforeUs / 1000L) + 1) < lastTimeStamp.timestamp.endMs) {
return lastTimeStamp
}
}
Expand Down Expand Up @@ -999,7 +998,7 @@ class CS3IPlayer : IPlayer {
if (lastTimeStamp.skipToNextEpisode) {
handleEvent(CSPlayerEvent.NextEpisode, source)
} else {
seekTo(lastTimeStamp.endMs + 1L)
seekTo(lastTimeStamp.timestamp.endMs + 1L)
}
event(TimestampSkippedEvent(timestamp = lastTimeStamp, source = source))
}
Expand Down Expand Up @@ -1578,9 +1577,9 @@ class CS3IPlayer : IPlayer {
}
}

private var lastTimeStamps: List<EpisodeSkip.SkipStamp> = emptyList()
private var lastTimeStamps: List<VideoSkipStamp> = emptyList()

override fun addTimeStamps(timeStamps: List<EpisodeSkip.SkipStamp>) {
override fun addTimeStamps(timeStamps: List<VideoSkipStamp>) {
lastTimeStamps = timeStamps
timeStamps.forEach { timestamp ->
exoPlayer?.createMessage { _, _ ->
Expand All @@ -1589,7 +1588,7 @@ class CS3IPlayer : IPlayer {
// onTimestampInvoked?.invoke(payload)
}
?.setLooper(Looper.getMainLooper())
?.setPosition(timestamp.startMs)
?.setPosition(timestamp.timestamp.startMs)
//?.setPayload(timestamp)
?.setDeleteAfterDelivery(false)
?.send()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
import com.lagradost.cloudstream3.utils.Coroutines.runOnMainThread
import com.lagradost.cloudstream3.utils.DataStoreHelper
import com.lagradost.cloudstream3.utils.DataStoreHelper.getViewPos
import com.lagradost.cloudstream3.utils.EpisodeSkip
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.ExtractorLinkType
import com.lagradost.cloudstream3.utils.Qualities
Expand All @@ -124,6 +123,7 @@ import com.lagradost.cloudstream3.utils.UIHelper.toPx
import com.lagradost.cloudstream3.utils.downloader.DownloadUtils.getImageBitmapFromUrl
import com.lagradost.cloudstream3.utils.setText
import com.lagradost.cloudstream3.utils.txt
import com.lagradost.cloudstream3.utils.videoskip.VideoSkipStamp
import com.lagradost.safefile.SafeFile
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
Expand Down Expand Up @@ -2052,11 +2052,11 @@ class GeneratorPlayer : FullScreenPlayer() {
}
}

override fun onTimestampSkipped(timestamp: EpisodeSkip.SkipStamp) {
override fun onTimestampSkipped(timestamp: VideoSkipStamp) {
displayTimeStamp(false)
}

override fun onTimestamp(timestamp: EpisodeSkip.SkipStamp?) {
override fun onTimestamp(timestamp: VideoSkipStamp?) {
if (timestamp != null) {
playerBinding?.skipChapterButton?.setText(timestamp.uiText)
displayTimeStamp(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import android.content.Context
import android.graphics.Bitmap
import android.util.Rational
import com.lagradost.cloudstream3.ui.subtitles.SaveCaptionStyle
import com.lagradost.cloudstream3.utils.EpisodeSkip
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.videoskip.VideoSkipStamp

enum class PlayerEventType(val value: Int) {
Pause(0),
Expand Down Expand Up @@ -86,13 +86,13 @@ data class ErrorEvent(

/** Event when timestamps appear, null when it should disappear */
data class TimestampInvokedEvent(
val timestamp: EpisodeSkip.SkipStamp,
val timestamp: VideoSkipStamp,
override val source: PlayerEventSource = PlayerEventSource.Player,
) : PlayerEvent()

/** Event for when a chapter is skipped, aka when event is handled (or for future use when skip automatically ads/sponsor) */
data class TimestampSkippedEvent(
val timestamp: EpisodeSkip.SkipStamp,
val timestamp: VideoSkipStamp,
override val source: PlayerEventSource = PlayerEventSource.Player,
) : PlayerEvent()

Expand Down Expand Up @@ -254,7 +254,7 @@ interface IPlayer {
fun updateSubtitleStyle(style: SaveCaptionStyle)
fun saveData()

fun addTimeStamps(timeStamps: List<EpisodeSkip.SkipStamp>)
fun addTimeStamps(timeStamps: List<VideoSkipStamp>)

fun loadPlayer(
context: Context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import com.lagradost.cloudstream3.mvvm.safe
import com.lagradost.cloudstream3.mvvm.safeApiCall
import com.lagradost.cloudstream3.ui.result.ResultEpisode
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
import com.lagradost.cloudstream3.utils.EpisodeSkip
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.ExtractorLinkType
import com.lagradost.cloudstream3.utils.videoskip.SkipAPI
import com.lagradost.cloudstream3.utils.videoskip.VideoSkipStamp
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch

Expand All @@ -35,8 +36,8 @@ class PlayerGeneratorViewModel : ViewModel() {
private val _loadingLinks = MutableLiveData<Resource<Boolean?>>()
val loadingLinks: LiveData<Resource<Boolean?>> = _loadingLinks

private val _currentStamps = MutableLiveData<List<EpisodeSkip.SkipStamp>>(emptyList())
val currentStamps: LiveData<List<EpisodeSkip.SkipStamp>> = _currentStamps
private val _currentStamps = MutableLiveData<List<VideoSkipStamp>>(emptyList())
val currentStamps: LiveData<List<VideoSkipStamp>> = _currentStamps

private val _currentSubtitleYear = MutableLiveData<Int?>(null)
val currentSubtitleYear: LiveData<Int?> = _currentSubtitleYear
Expand Down Expand Up @@ -181,7 +182,7 @@ class PlayerGeneratorViewModel : ViewModel() {
if (page != null && meta is ResultEpisode) {
_currentStamps.postValue(listOf())
_currentStamps.postValue(
EpisodeSkip.getStamps(
SkipAPI.videoStamps(
page,
meta,
duration,
Expand Down
Loading