Я использую Media3 в JetPack Compose. Я изо всех сил пытаюсь реализовать PIP. Когда показан PIP, видео не изменяется должным образом. Я прикрепляю скриншоты ниже.
.
Вот мой код. < /p>
Box(
modifier = modifier
) {
PipActionReceiver(exoPlayer, isInPictureInPictureMode)
AndroidView(
factory = {
playerView.also {
it.requestFocus()
}
},
update = {
it.player = exoPlayer.also { player ->
player.addListener(exoPlayerListener)
}
it.setShowBuffering(PlayerView.SHOW_BUFFERING_WHEN_PLAYING)
it.setControllerAnimationEnabled(false)
it.setShowFastForwardButton(true)
it.setShowRewindButton(true)
it.setShowNextButton(false)
it.setShowPreviousButton(false)
it.showController()
it.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL)
it.setControllerVisibilityListener(PlayerView.ControllerVisibilityListener { isVisible ->
isControllerVisible = isVisible == View.VISIBLE
Log.d(LogTag,"ControllerVisibilityListener $isControllerVisible")
it.subtitleView?.adjustSubtitlePosition(context, isControllerVisible, it.height)
})
it.artworkDisplayMode = ARTWORK_DISPLAY_MODE_FILL
it.setShowSubtitleButton(true)
it.setErrorMessageProvider(PlayerErrorMessageProvider(context))
},
modifier = Modifier
.fillMaxSize()
.zIndex(1f)
.focusable(
enabled = true,
interactionSource = interactionSource
)
.focusRequester(focusRequester)
.onGloballyPositioned {
playerRect = it
.boundsInWindow()
.toAndroidRect()
}
.then(
if (DeviceType.isTv(context))
Modifier.onKeyEvent { keyEvent ->
Log.d(LogTag, "onKeyEvent in main player $keyEvent")
// Detecting back button press
if (keyEvent.nativeKeyEvent.keyCode == KeyEvent.KEYCODE_BACK && keyEvent.nativeKeyEvent.action == KeyEvent.ACTION_DOWN) {
when {
currentDialogType != TrackSettingsDialogType.None -> {
currentDialogType = TrackSettingsDialogType.None
}
else -> {
releasePlayer()
onGotoBackScreen()
}
}
true // Consuming the back press event
} else if (keyEvent.nativeKeyEvent.keyCode == KeyEvent.KEYCODE_DPAD_CENTER && keyEvent.nativeKeyEvent.action == KeyEvent.ACTION_DOWN) {
if (isControllerVisible && playerView.findTimeBar().isFocused) {
playerView.togglePlayPause()
} else if (!isControllerVisible) {
playerView.apply {
showController()
findTimeBar().requestFocus()
playerView.togglePlayPause()
}
}
true
} else {
// Handle other key events, including showing the controller when necessary
if (isControllerVisible) {
playerView.dispatchKeyEvent(keyEvent.nativeKeyEvent)
} else {
playerView.showController()
playerView.findTimeBar().requestFocus()
true//Don't send key press event
}
}
}
else
Modifier
),
)
< /code>
и для обновления PIP Params < /p>
fun updatePipParams(
context: Context,
videoInfo: VideoInfo,
videoViewBounds: Rect,
isPlaying: Boolean,
): PictureInPictureParams? {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
PictureInPictureParams.Builder()
.setAspectRatio(Rational(16, 9))
.also {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
it.setExpandedAspectRatio(Rational(4, 3))
it.setTitle(videoInfo.title)
it.setSubtitle(videoInfo.artistName)
it.setSeamlessResizeEnabled(true)
it.setActions(
listOfRemoteActions(isPlaying, context)
)
}
context.findActivity()?.setPictureInPictureParams(it.build())
}
.build()
} else null
}
< /code>
и использование < /p>
setOnClickListener {
updatePipParams(context, videoInfo, playerRect, exoPlayer.isPlaying)?.let { params ->
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (activity.enterPictureInPictureMode(params)) {
Log.d(LogTag, "Entered PiP mode")
findControllerLayout().isVisible(false)
onPresentationChanged(PlayerPresentationModes.PIP)
} else {
Log.e(LogTag, "Failed to enter PiP mode")
}
}
}
}
< /code>
Я также попытался переключить зум, заполнить и подходить. Ничего не помогло.
Как я могу исправить его, чтобы отобрать видео в PIP в как смягченное, так и расширенное окно с правильно масштабированным и измененным видео. < /P>
Подробнее здесь: https://stackoverflow.com/questions/794 ... ose-media3
Видео Exoplayer не изменяется в PIP - JetPack Compose -Media3 ⇐ Android
Форум для тех, кто программирует под Android
-
Anonymous
1738980144
Anonymous
Я использую Media3 в JetPack Compose. Я изо всех сил пытаюсь реализовать PIP. Когда показан PIP, видео не изменяется должным образом. Я прикрепляю скриншоты ниже.
.
Вот мой код. < /p>
Box(
modifier = modifier
) {
PipActionReceiver(exoPlayer, isInPictureInPictureMode)
AndroidView(
factory = {
playerView.also {
it.requestFocus()
}
},
update = {
it.player = exoPlayer.also { player ->
player.addListener(exoPlayerListener)
}
it.setShowBuffering(PlayerView.SHOW_BUFFERING_WHEN_PLAYING)
it.setControllerAnimationEnabled(false)
it.setShowFastForwardButton(true)
it.setShowRewindButton(true)
it.setShowNextButton(false)
it.setShowPreviousButton(false)
it.showController()
it.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL)
it.setControllerVisibilityListener(PlayerView.ControllerVisibilityListener { isVisible ->
isControllerVisible = isVisible == View.VISIBLE
Log.d(LogTag,"ControllerVisibilityListener $isControllerVisible")
it.subtitleView?.adjustSubtitlePosition(context, isControllerVisible, it.height)
})
it.artworkDisplayMode = ARTWORK_DISPLAY_MODE_FILL
it.setShowSubtitleButton(true)
it.setErrorMessageProvider(PlayerErrorMessageProvider(context))
},
modifier = Modifier
.fillMaxSize()
.zIndex(1f)
.focusable(
enabled = true,
interactionSource = interactionSource
)
.focusRequester(focusRequester)
.onGloballyPositioned {
playerRect = it
.boundsInWindow()
.toAndroidRect()
}
.then(
if (DeviceType.isTv(context))
Modifier.onKeyEvent { keyEvent ->
Log.d(LogTag, "onKeyEvent in main player $keyEvent")
// Detecting back button press
if (keyEvent.nativeKeyEvent.keyCode == KeyEvent.KEYCODE_BACK && keyEvent.nativeKeyEvent.action == KeyEvent.ACTION_DOWN) {
when {
currentDialogType != TrackSettingsDialogType.None -> {
currentDialogType = TrackSettingsDialogType.None
}
else -> {
releasePlayer()
onGotoBackScreen()
}
}
true // Consuming the back press event
} else if (keyEvent.nativeKeyEvent.keyCode == KeyEvent.KEYCODE_DPAD_CENTER && keyEvent.nativeKeyEvent.action == KeyEvent.ACTION_DOWN) {
if (isControllerVisible && playerView.findTimeBar().isFocused) {
playerView.togglePlayPause()
} else if (!isControllerVisible) {
playerView.apply {
showController()
findTimeBar().requestFocus()
playerView.togglePlayPause()
}
}
true
} else {
// Handle other key events, including showing the controller when necessary
if (isControllerVisible) {
playerView.dispatchKeyEvent(keyEvent.nativeKeyEvent)
} else {
playerView.showController()
playerView.findTimeBar().requestFocus()
true//Don't send key press event
}
}
}
else
Modifier
),
)
< /code>
и для обновления PIP Params < /p>
fun updatePipParams(
context: Context,
videoInfo: VideoInfo,
videoViewBounds: Rect,
isPlaying: Boolean,
): PictureInPictureParams? {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
PictureInPictureParams.Builder()
.setAspectRatio(Rational(16, 9))
.also {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
it.setExpandedAspectRatio(Rational(4, 3))
it.setTitle(videoInfo.title)
it.setSubtitle(videoInfo.artistName)
it.setSeamlessResizeEnabled(true)
it.setActions(
listOfRemoteActions(isPlaying, context)
)
}
context.findActivity()?.setPictureInPictureParams(it.build())
}
.build()
} else null
}
< /code>
и использование < /p>
setOnClickListener {
updatePipParams(context, videoInfo, playerRect, exoPlayer.isPlaying)?.let { params ->
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (activity.enterPictureInPictureMode(params)) {
Log.d(LogTag, "Entered PiP mode")
findControllerLayout().isVisible(false)
onPresentationChanged(PlayerPresentationModes.PIP)
} else {
Log.e(LogTag, "Failed to enter PiP mode")
}
}
}
}
< /code>
Я также попытался переключить зум, заполнить и подходить. Ничего не помогло.
Как я могу исправить его, чтобы отобрать видео в PIP в как смягченное, так и расширенное окно с правильно масштабированным и измененным видео. < /P>
Подробнее здесь: [url]https://stackoverflow.com/questions/79422521/exoplayer-video-not-resizing-in-pip-jetpack-compose-media3[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия