Importing ExoPlayer for Unity
Importing
Unity 2019.2+
-
Create or Open target Unity project
-
Import ExoPlayer for Unity asset package
- Switch to Android platform
- File –> Build Settings –> Platform –> Select Android and Switch Platform
- Enable Custom Main Gradle Template
- Edit –> Project Settings –> Publishing Settings –> check
Custom Main Gradle Template
- Open
Assets/Plugins/Android/mainTemplate.gradle
with any text editor - Add below line inside
dependencies { }
implementation 'com.google.android.exoplayer:exoplayer:2.12.2'
- It will be look like this
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.google.android.exoplayer:exoplayer:2.12.2' **DEPS**}
- Edit –> Project Settings –> Publishing Settings –> check
- Set Graphics API
- Edit –> Project Settings –> Other Settings –> Graphics API
- Remove Vulkan
- Add OpenGL ES 2.0 or OpenGL ES 3.0
- Disable Multithreaded Rendering option
- Edit –> Project Settings –> Other Settings –> uncheck
Multithreaded Rendering
- Edit –> Project Settings –> Other Settings –> uncheck
- Set Minimum API Level to API Level 28 or later
- Edit –> Project Settings –> Other Settings –> Minimum API Level
- set to API Level 28 or later
- Enable Internet access to test sample scenes
- Edit –> Project Settings –> Other Settings –> Internet Access
- set to Require
Unity 2020.x
- Follow import instruction for Unity 2019.2+
- Enable Custom Base Gradle Template
- Edit –> Project Settings –> Publishing Settings –> check
Custom Base Gradle Template
- Open
Assets/Plugins/Android/baseProjectTemplate.gradle
with any text editor, and change version of gradle plugin to 3.4.0classpath 'com.android.tools.build:gradle:3.4.0'
- Edit –> Project Settings –> Publishing Settings –> check
Demo Scenes
SampleVideoPlayer
- provides simple video player interface
- play, pause, stop, previous media, next media, rewind, forward
SampleVideoCubes
- provides simple video rendering on texture object
Sample360Video
- shows playing a 360 video on a texture object, which is mapped on a sphere object