readd regular video elements for regular playing, use isVideo funtion to check
This commit is contained in:
@@ -109,9 +109,12 @@ import com.vitorpamplona.amethyst.ui.note.MutedIcon
|
|||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.stringRes
|
import com.vitorpamplona.amethyst.ui.stringRes
|
||||||
import com.vitorpamplona.amethyst.ui.theme.PinBottomIconSize
|
import com.vitorpamplona.amethyst.ui.theme.PinBottomIconSize
|
||||||
|
import com.vitorpamplona.amethyst.ui.theme.Size110dp
|
||||||
|
import com.vitorpamplona.amethyst.ui.theme.Size165dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size20Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size20Modifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size22Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size22Modifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size50Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size50Modifier
|
||||||
|
import com.vitorpamplona.amethyst.ui.theme.Size55dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size75dp
|
import com.vitorpamplona.amethyst.ui.theme.Size75dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.VolumeBottomIconSize
|
import com.vitorpamplona.amethyst.ui.theme.VolumeBottomIconSize
|
||||||
import com.vitorpamplona.amethyst.ui.theme.imageModifier
|
import com.vitorpamplona.amethyst.ui.theme.imageModifier
|
||||||
@@ -754,73 +757,78 @@ private fun RenderVideoPlayer(
|
|||||||
} else {
|
} else {
|
||||||
AspectRatioFrameLayout.RESIZE_MODE_FIXED_WIDTH
|
AspectRatioFrameLayout.RESIZE_MODE_FIXED_WIDTH
|
||||||
}
|
}
|
||||||
/*onDialog?.let { innerOnDialog ->
|
if (!gallery) {
|
||||||
setFullscreenButtonClickListener {
|
onDialog?.let { innerOnDialog ->
|
||||||
controller.pause()
|
setFullscreenButtonClickListener {
|
||||||
innerOnDialog(it)
|
controller.pause()
|
||||||
|
innerOnDialog(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
setControllerVisibilityListener(
|
||||||
|
PlayerView.ControllerVisibilityListener { visible ->
|
||||||
|
controllerVisible.value = visible == View.VISIBLE
|
||||||
|
onControllerVisibilityChanged?.let { callback -> callback(visible == View.VISIBLE) }
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
setControllerVisibilityListener(
|
|
||||||
PlayerView.ControllerVisibilityListener { visible ->
|
|
||||||
controllerVisible.value = visible == View.VISIBLE
|
|
||||||
onControllerVisibilityChanged?.let { callback -> callback(visible == View.VISIBLE) }
|
|
||||||
},
|
|
||||||
) */
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
/*
|
|
||||||
waveform?.let { Waveform(it, controller, remember { Modifier.align(Alignment.Center) }) }
|
waveform?.let { Waveform(it, controller, remember { Modifier.align(Alignment.Center) }) }
|
||||||
|
if (!gallery) {
|
||||||
|
val startingMuteState = remember(controller) { controller.volume < 0.001 }
|
||||||
|
|
||||||
val startingMuteState = remember(controller) { controller.volume < 0.001 }
|
MuteButton(
|
||||||
|
controllerVisible,
|
||||||
|
startingMuteState,
|
||||||
|
Modifier.align(Alignment.TopEnd),
|
||||||
|
) { mute: Boolean ->
|
||||||
|
// makes the new setting the default for new creations.
|
||||||
|
DEFAULT_MUTED_SETTING.value = mute
|
||||||
|
|
||||||
MuteButton(
|
// if the user unmutes a video and it's not the current playing, switches to that one.
|
||||||
controllerVisible,
|
if (!mute && keepPlayingMutex != null && keepPlayingMutex != controller) {
|
||||||
startingMuteState,
|
|
||||||
Modifier.align(Alignment.TopEnd),
|
|
||||||
) { mute: Boolean ->
|
|
||||||
// makes the new setting the default for new creations.
|
|
||||||
DEFAULT_MUTED_SETTING.value = mute
|
|
||||||
|
|
||||||
// if the user unmutes a video and it's not the current playing, switches to that one.
|
|
||||||
if (!mute && keepPlayingMutex != null && keepPlayingMutex != controller) {
|
|
||||||
keepPlayingMutex?.stop()
|
|
||||||
keepPlayingMutex?.release()
|
|
||||||
keepPlayingMutex = null
|
|
||||||
}
|
|
||||||
|
|
||||||
controller.volume = if (mute) 0f else 1f
|
|
||||||
}
|
|
||||||
|
|
||||||
KeepPlayingButton(
|
|
||||||
keepPlaying,
|
|
||||||
controllerVisible,
|
|
||||||
Modifier.align(Alignment.TopEnd).padding(end = Size55dp),
|
|
||||||
) { newKeepPlaying: Boolean ->
|
|
||||||
// If something else is playing and the user marks this video to keep playing, stops the other
|
|
||||||
// one.
|
|
||||||
if (newKeepPlaying) {
|
|
||||||
if (keepPlayingMutex != null && keepPlayingMutex != controller) {
|
|
||||||
keepPlayingMutex?.stop()
|
keepPlayingMutex?.stop()
|
||||||
keepPlayingMutex?.release()
|
keepPlayingMutex?.release()
|
||||||
}
|
|
||||||
keepPlayingMutex = controller
|
|
||||||
} else {
|
|
||||||
if (keepPlayingMutex == controller) {
|
|
||||||
keepPlayingMutex = null
|
keepPlayingMutex = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
controller.volume = if (mute) 0f else 1f
|
||||||
}
|
}
|
||||||
|
|
||||||
keepPlaying.value = newKeepPlaying
|
KeepPlayingButton(
|
||||||
}
|
keepPlaying,
|
||||||
|
controllerVisible,
|
||||||
|
Modifier.align(Alignment.TopEnd).padding(end = Size55dp),
|
||||||
|
) { newKeepPlaying: Boolean ->
|
||||||
|
// If something else is playing and the user marks this video to keep playing, stops the other
|
||||||
|
// one.
|
||||||
|
if (newKeepPlaying) {
|
||||||
|
if (keepPlayingMutex != null && keepPlayingMutex != controller) {
|
||||||
|
keepPlayingMutex?.stop()
|
||||||
|
keepPlayingMutex?.release()
|
||||||
|
}
|
||||||
|
keepPlayingMutex = controller
|
||||||
|
} else {
|
||||||
|
if (keepPlayingMutex == controller) {
|
||||||
|
keepPlayingMutex = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AnimatedSaveButton(controllerVisible, Modifier.align(Alignment.TopEnd).padding(end = Size110dp)) { context ->
|
keepPlaying.value = newKeepPlaying
|
||||||
saveImage(videoUri, mimeType, context, accountViewModel)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
AnimatedShareButton(controllerVisible, Modifier.align(Alignment.TopEnd).padding(end = Size165dp)) { popupExpanded, toggle ->
|
AnimatedSaveButton(controllerVisible, Modifier.align(Alignment.TopEnd).padding(end = Size110dp)) { context ->
|
||||||
ShareImageAction(accountViewModel = accountViewModel, popupExpanded, videoUri, nostrUriCallback, toggle)
|
saveImage(videoUri, mimeType, context, accountViewModel)
|
||||||
} */
|
}
|
||||||
|
|
||||||
|
AnimatedShareButton(controllerVisible, Modifier.align(Alignment.TopEnd).padding(end = Size165dp)) { popupExpanded, toggle ->
|
||||||
|
ShareImageAction(accountViewModel = accountViewModel, popupExpanded, videoUri, nostrUriCallback, toggle)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
controller.volume = 0f
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -53,6 +53,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
|||||||
import androidx.lifecycle.distinctUntilChanged
|
import androidx.lifecycle.distinctUntilChanged
|
||||||
import androidx.lifecycle.map
|
import androidx.lifecycle.map
|
||||||
import coil.compose.AsyncImage
|
import coil.compose.AsyncImage
|
||||||
|
import com.vitorpamplona.amethyst.commons.richtext.RichTextParser.Companion.isVideoUrl
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.ui.actions.CrossfadeIfEnabled
|
import com.vitorpamplona.amethyst.ui.actions.CrossfadeIfEnabled
|
||||||
import com.vitorpamplona.amethyst.ui.components.SensitivityWarning
|
import com.vitorpamplona.amethyst.ui.components.SensitivityWarning
|
||||||
@@ -336,8 +337,7 @@ fun InnerRenderGalleryThumb(
|
|||||||
contentAlignment = BottomStart,
|
contentAlignment = BottomStart,
|
||||||
) {
|
) {
|
||||||
card.image?.let {
|
card.image?.let {
|
||||||
if (it.endsWith("mp4") || it.endsWith("mov") || it.endsWith("mpeg")) {
|
if (isVideoUrl(it)) {
|
||||||
// TODO how to long press?
|
|
||||||
VideoView(
|
VideoView(
|
||||||
videoUri = it,
|
videoUri = it,
|
||||||
mimeType = null,
|
mimeType = null,
|
||||||
|
|||||||
Reference in New Issue
Block a user