- Activates support for m3u8 streaming
- BugFix on restarting the video when pressing mute.
This commit is contained in:
@@ -67,7 +67,7 @@ import java.net.URL
|
|||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
val imageExtensions = listOf("png", "jpg", "gif", "bmp", "jpeg", "webp", "svg")
|
val imageExtensions = listOf("png", "jpg", "gif", "bmp", "jpeg", "webp", "svg")
|
||||||
val videoExtensions = listOf("mp4", "avi", "wmv", "mpg", "amv", "webm", "mov", "mp3")
|
val videoExtensions = listOf("mp4", "avi", "wmv", "mpg", "amv", "webm", "mov", "mp3", "m3u8")
|
||||||
|
|
||||||
// Group 1 = url, group 4 additional chars
|
// Group 1 = url, group 4 additional chars
|
||||||
val noProtocolUrlValidator = Pattern.compile("(([\\w\\d-]+\\.)*[a-zA-Z][\\w-]+[\\.\\:]\\w+([\\/\\?\\=\\&\\#\\.]?[\\w-]+)*\\/?)(.*)")
|
val noProtocolUrlValidator = Pattern.compile("(([\\w\\d-]+\\.)*[a-zA-Z][\\w-]+[\\.\\:]\\w+([\\/\\?\\=\\&\\#\\.]?[\\w-]+)*\\/?)(.*)")
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ import com.google.android.exoplayer2.ExoPlayer
|
|||||||
import com.google.android.exoplayer2.MediaItem
|
import com.google.android.exoplayer2.MediaItem
|
||||||
import com.google.android.exoplayer2.Player
|
import com.google.android.exoplayer2.Player
|
||||||
import com.google.android.exoplayer2.source.ProgressiveMediaSource
|
import com.google.android.exoplayer2.source.ProgressiveMediaSource
|
||||||
|
import com.google.android.exoplayer2.source.hls.HlsMediaSource
|
||||||
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout
|
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout
|
||||||
import com.google.android.exoplayer2.ui.StyledPlayerView
|
import com.google.android.exoplayer2.ui.StyledPlayerView
|
||||||
import com.vitorpamplona.amethyst.VideoCache
|
import com.vitorpamplona.amethyst.VideoCache
|
||||||
@@ -101,6 +102,7 @@ fun VideoView(
|
|||||||
onDialog: ((Boolean) -> Unit)? = null
|
onDialog: ((Boolean) -> Unit)? = null
|
||||||
) {
|
) {
|
||||||
var exoPlayerData by remember { mutableStateOf<VideoPlayer?>(null) }
|
var exoPlayerData by remember { mutableStateOf<VideoPlayer?>(null) }
|
||||||
|
val defaultToStart by remember { mutableStateOf(DefaultMutedSetting.value) }
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
LaunchedEffect(key1 = videoUri) {
|
LaunchedEffect(key1 = videoUri) {
|
||||||
@@ -112,7 +114,7 @@ fun VideoView(
|
|||||||
}
|
}
|
||||||
|
|
||||||
exoPlayerData?.let {
|
exoPlayerData?.let {
|
||||||
VideoView(videoUri, description, it, thumb, onDialog)
|
VideoView(videoUri, description, it, defaultToStart, thumb, onDialog)
|
||||||
}
|
}
|
||||||
|
|
||||||
DisposableEffect(Unit) {
|
DisposableEffect(Unit) {
|
||||||
@@ -127,6 +129,7 @@ fun VideoView(
|
|||||||
videoUri: String,
|
videoUri: String,
|
||||||
description: String? = null,
|
description: String? = null,
|
||||||
exoPlayerData: VideoPlayer,
|
exoPlayerData: VideoPlayer,
|
||||||
|
defaultToStart: Boolean = false,
|
||||||
thumb: VideoThumb? = null,
|
thumb: VideoThumb? = null,
|
||||||
onDialog: ((Boolean) -> Unit)? = null
|
onDialog: ((Boolean) -> Unit)? = null
|
||||||
) {
|
) {
|
||||||
@@ -137,9 +140,15 @@ fun VideoView(
|
|||||||
exoPlayerData.exoPlayer.apply {
|
exoPlayerData.exoPlayer.apply {
|
||||||
repeatMode = Player.REPEAT_MODE_ALL
|
repeatMode = Player.REPEAT_MODE_ALL
|
||||||
videoScalingMode = C.VIDEO_SCALING_MODE_SCALE_TO_FIT
|
videoScalingMode = C.VIDEO_SCALING_MODE_SCALE_TO_FIT
|
||||||
volume = if (DefaultMutedSetting.value) 0f else 1f
|
volume = if (defaultToStart) 0f else 1f
|
||||||
if (videoUri.startsWith("file") == true) {
|
if (videoUri.startsWith("file")) {
|
||||||
setMediaItem(media)
|
setMediaItem(media)
|
||||||
|
} else if (videoUri.endsWith("m3u8")) {
|
||||||
|
setMediaSource(
|
||||||
|
HlsMediaSource.Factory(VideoCache.get()).createMediaSource(
|
||||||
|
media
|
||||||
|
)
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
setMediaSource(
|
setMediaSource(
|
||||||
ProgressiveMediaSource.Factory(VideoCache.get()).createMediaSource(
|
ProgressiveMediaSource.Factory(VideoCache.get()).createMediaSource(
|
||||||
|
|||||||
@@ -195,25 +195,17 @@ object MessagesLatestItem : LatestItem() {
|
|||||||
account: Account,
|
account: Account,
|
||||||
newNotes: Set<Note>
|
newNotes: Set<Note>
|
||||||
): Boolean {
|
): Boolean {
|
||||||
println("AAA Hey")
|
|
||||||
|
|
||||||
// Checks if the current newest item is still unread.
|
// Checks if the current newest item is still unread.
|
||||||
// If so, there is no need to check anything else
|
// If so, there is no need to check anything else
|
||||||
if (isNew(getNewestItem(account), account)) {
|
if (isNew(getNewestItem(account), account)) {
|
||||||
println("AAA Enter ${getNewestItem(account)?.author?.toBestDisplayName()}")
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
clearNewestItem(account)
|
clearNewestItem(account)
|
||||||
|
|
||||||
println("AAA Hey 2")
|
|
||||||
|
|
||||||
// gets the newest of the unread items
|
// gets the newest of the unread items
|
||||||
val newestItem = updateNewestItem(newNotes, account, ChatroomListKnownFeedFilter(account))
|
val newestItem = updateNewestItem(newNotes, account, ChatroomListKnownFeedFilter(account))
|
||||||
|
|
||||||
println("AAA ${newestItem?.author?.toBestDisplayName()} ${isNew(newestItem, account)}")
|
|
||||||
|
|
||||||
return isNew(newestItem, account)
|
return isNew(newestItem, account)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user