I'm trying to move or rotate 360 spherical video in Android TV by using D-pad, but its rotating the player, not the spherical video.
tried with ExoPlayer and androidx.media3.exoplayer.ExoPlayer
Xml:
<androidx.media3.ui.PlayerView
android:id="@+id/playerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:show_buffering="always"
app:show_subtitle_button="true"
app:surface_type="spherical_gl_surface_view"
app:use_controller="true" />
Code:
...
private lateinit var playerView: PlayerView
private lateinit var player: ExoPlayer
//rest implementation
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
when (keyCode) {
KeyEvent.KEYCODE_DPAD_LEFT -> {
// Move left (yaw left)
yawDegrees -= 100f // Adjust the angle as needed
updateRotation()
return true
}
KeyEvent.KEYCODE_DPAD_RIGHT -> {
// Move right (yaw right)
yawDegrees += 100f // Adjust the angle as needed
updateRotation()
return true
}
return super.onKeyDown(keyCode, event)
}
private fun updateRotation() {
playerView.videoSurfaceView?.rotation = yawDegrees
}
...
Apparently the SphericalGLSurfaceView does not support any rotation information source other than touch or orientation.
My suggestion is to basically copy the class from Google and modify it to your needs. (You're unable to subclass or modify without hacky reflection due to the private/final declarations).
So basically:
RendererRendererinner class which will updatetouchPitchandtouchYawMatrixand callsupdatePitchMatrix()or something. (I would investigate theonScrollChangemethod to figure out what values need manipulation and try around a bit)surfaceViewon the Player after creating it. (Because that had to be private and final as well...). Also reset the params from the old surfaceView (see this for reference)