make newplayer be able to open the Audio UI
This commit is contained in:
parent
87cc8a2c77
commit
5046122732
|
@ -207,6 +207,7 @@ fun PlaySurface(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OptIn(UnstableApi::class)
|
||||||
@Preview(device = "spec:width=1080px,height=700px,dpi=440,orientation=landscape")
|
@Preview(device = "spec:width=1080px,height=700px,dpi=440,orientation=landscape")
|
||||||
@Composable
|
@Composable
|
||||||
fun PlayerUIPreviewEmbeded() {
|
fun PlayerUIPreviewEmbeded() {
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
package net.newpipe.newplayer.ui.videoplayer.controller
|
package net.newpipe.newplayer.ui.videoplayer.controller
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import androidx.annotation.OptIn
|
import androidx.annotation.OptIn
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
@ -28,6 +29,7 @@ import androidx.compose.material.icons.automirrored.filled.VolumeUp
|
||||||
import androidx.compose.material.icons.filled.FitScreen
|
import androidx.compose.material.icons.filled.FitScreen
|
||||||
import androidx.compose.material.icons.filled.Language
|
import androidx.compose.material.icons.filled.Language
|
||||||
import androidx.compose.material.icons.filled.MoreVert
|
import androidx.compose.material.icons.filled.MoreVert
|
||||||
|
import androidx.compose.material.icons.filled.MusicNote
|
||||||
import androidx.compose.material.icons.filled.Share
|
import androidx.compose.material.icons.filled.Share
|
||||||
import androidx.compose.material.icons.filled.Subtitles
|
import androidx.compose.material.icons.filled.Subtitles
|
||||||
import androidx.compose.material.icons.filled.Translate
|
import androidx.compose.material.icons.filled.Translate
|
||||||
|
@ -44,6 +46,7 @@ import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.layout.onPlaced
|
import androidx.compose.ui.layout.onPlaced
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalDensity
|
import androidx.compose.ui.platform.LocalDensity
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
@ -51,10 +54,13 @@ import androidx.compose.ui.unit.DpOffset
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.media3.common.util.UnstableApi
|
import androidx.media3.common.util.UnstableApi
|
||||||
import net.newpipe.newplayer.R
|
import net.newpipe.newplayer.R
|
||||||
|
import net.newpipe.newplayer.model.EmbeddedUiConfig
|
||||||
import net.newpipe.newplayer.model.NewPlayerUIState
|
import net.newpipe.newplayer.model.NewPlayerUIState
|
||||||
import net.newpipe.newplayer.model.NewPlayerViewModel
|
import net.newpipe.newplayer.model.NewPlayerViewModel
|
||||||
import net.newpipe.newplayer.model.NewPlayerViewModelDummy
|
import net.newpipe.newplayer.model.NewPlayerViewModelDummy
|
||||||
|
import net.newpipe.newplayer.model.UIModeState
|
||||||
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
|
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
|
||||||
|
import net.newpipe.newplayer.utils.getEmbeddedUiConfig
|
||||||
|
|
||||||
@OptIn(UnstableApi::class)
|
@OptIn(UnstableApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
|
@ -67,6 +73,11 @@ fun DropDownMenu(viewModel: NewPlayerViewModel, uiState: NewPlayerUIState) {
|
||||||
mutableStateOf(0.dp)
|
mutableStateOf(0.dp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val embeddedUiConfig = if (LocalContext.current is Activity)
|
||||||
|
getEmbeddedUiConfig(activity = LocalContext.current as Activity)
|
||||||
|
else
|
||||||
|
EmbeddedUiConfig.DUMMY
|
||||||
|
|
||||||
Box {
|
Box {
|
||||||
IconButton(onClick = {
|
IconButton(onClick = {
|
||||||
showMainMenu = true
|
showMainMenu = true
|
||||||
|
@ -85,7 +96,8 @@ fun DropDownMenu(viewModel: NewPlayerViewModel, uiState: NewPlayerUIState) {
|
||||||
DropdownMenu(modifier = Modifier.align(Alignment.TopStart),
|
DropdownMenu(modifier = Modifier.align(Alignment.TopStart),
|
||||||
offset = DpOffset(x = 0.dp, y = -offsetY),
|
offset = DpOffset(x = 0.dp, y = -offsetY),
|
||||||
expanded = showMainMenu,
|
expanded = showMainMenu,
|
||||||
onDismissRequest = { showMainMenu = false
|
onDismissRequest = {
|
||||||
|
showMainMenu = false
|
||||||
viewModel.dialogVisible(false)
|
viewModel.dialogVisible(false)
|
||||||
}) {
|
}) {
|
||||||
DropdownMenuItem(text = { Text(stringResource(R.string.menu_item_open_in_browser)) },
|
DropdownMenuItem(text = { Text(stringResource(R.string.menu_item_open_in_browser)) },
|
||||||
|
@ -104,12 +116,15 @@ fun DropDownMenu(viewModel: NewPlayerViewModel, uiState: NewPlayerUIState) {
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
onClick = { /*TODO*/ showMainMenu = false })
|
onClick = { /*TODO*/ showMainMenu = false })
|
||||||
DropdownMenuItem(text = { Text(stringResource(R.string.mute)) }, leadingIcon = {
|
DropdownMenuItem(text = { Text(stringResource(R.string.audio_mode)) }, leadingIcon = {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.AutoMirrored.Filled.VolumeUp,
|
imageVector = Icons.Filled.MusicNote,
|
||||||
contentDescription = stringResource(R.string.mute)
|
contentDescription = stringResource(R.string.audio_mode)
|
||||||
)
|
)
|
||||||
}, onClick = { /*TODO*/ showMainMenu = false })
|
}, onClick = {
|
||||||
|
viewModel.changeUiMode(UIModeState.FULLSCREEN_AUDIO, embeddedUiConfig)
|
||||||
|
showMainMenu = false
|
||||||
|
})
|
||||||
DropdownMenuItem(text = { Text(stringResource(R.string.menu_item_fit_screen)) },
|
DropdownMenuItem(text = { Text(stringResource(R.string.menu_item_fit_screen)) },
|
||||||
leadingIcon = {
|
leadingIcon = {
|
||||||
Icon(
|
Icon(
|
||||||
|
|
|
@ -23,8 +23,7 @@
|
||||||
<string name="menu_item_open_in_browser">Open in browser</string>
|
<string name="menu_item_open_in_browser">Open in browser</string>
|
||||||
<string name="menu_item_share_timestamp">Share timestamp</string>
|
<string name="menu_item_share_timestamp">Share timestamp</string>
|
||||||
<string name="menu_item_more_settings">More settings</string>
|
<string name="menu_item_more_settings">More settings</string>
|
||||||
<string name="mute">Mute</string>
|
<string name="audio_mode">Audio Mode</string>
|
||||||
<string name="unmute">Unmute</string>
|
|
||||||
<string name="menu_item_fit_screen">Fit screen</string>
|
<string name="menu_item_fit_screen">Fit screen</string>
|
||||||
<string name="menu_item_sub_titles">Subtitles</string>
|
<string name="menu_item_sub_titles">Subtitles</string>
|
||||||
<string name="menu_item_language">Language</string>
|
<string name="menu_item_language">Language</string>
|
||||||
|
|
Loading…
Reference in New Issue