Как включить GyroSensors для видео Exoplayer 360 - PullRequest
0 голосов
/ 11 февраля 2020

Я разрабатываю пользовательский плеер на основе Exoplayer для воспроизведения VR-видео. Мне удалось создать упрощенную версию, используя SimpleExoPlayer, однако, хотя я перемещаю свое устройство, VR-плеер не вращается так, как должен.

Затем я попробовал демоверсию Exoplayer, и она полностью заработала. Однако я не смог изменить код под свои нужды, поэтому пришлось начинать с нуля. Как я уже упоминал, мне удалось создать очень упрощенную версию. однако гироскопические датчики не вращают видео. Интересно, чего мне не хватает.

Вот мой VRPlayerActivity:

class VRPlayerActivity : AppCompatActivity() {

    private val mp4VideoUri: Uri? = Uri.parse("https://theyouthbuzz.com/ytplayer/Seoul8KVR3DTrailer.mp4")

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_vrplayer)
        val player = SimpleExoPlayer.Builder(this).build()
        val playerView = findViewById<SimpleExoPlayerView>(R.id.player_view)

        // Produces DataSource instances through which media data is loaded.
        // Produces DataSource instances through which media data is loaded.
        val dataSourceFactory: DataSource.Factory = DefaultDataSourceFactory(
            this,
            Util.getUserAgent(this, "YouthBuzz")
        )
        // This is the MediaSource representing the media to be played.
        // This is the MediaSource representing the media to be played.
        val videoSource: MediaSource = ProgressiveMediaSource.Factory(dataSourceFactory)
            .createMediaSource(mp4VideoUri)
        // Prepare the player with the source.
        // Prepare the player with the source.
        player.prepare(videoSource)
        (playerView.videoSurfaceView as SphericalGLSurfaceView?)!!.setDefaultStereoMode(
            C.STEREO_MODE_TOP_BOTTOM
        )

        playerView.player = player

    }
}

Вот мой activity_vrplayer.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:background="#0099cc"
    tools:context="._views.VRPlayer.VRPlayerActivity">

    <!-- The primary full-screen view. This can be replaced with whatever view
         is needed to present your content, e.g. VideoView, SurfaceView,
         TextureView, etc. -->
    <com.google.android.exoplayer2.ui.SimpleExoPlayerView
        android:id="@+id/player_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:surface_type="spherical_gl_surface_view"/>

</FrameLayout>
...