Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.camilasousa:ExoMedia:4.0.0-preview1'
}
dependencies {
implementation("com.github.camilasousa:ExoMedia:4.0.0-preview1")
}
<dependency>
<groupId>com.github.camilasousa</groupId>
<artifactId>ExoMedia</artifactId>
<version>4.0.0-preview1</version>
</dependency>
libraryDependencies += "com.github.camilasousa" % "ExoMedia" % "4.0.0-preview1"
:dependencies [[com.github.camilasousa/ExoMedia "4.0.0-preview1"]]
ExoMedia is a media playback library with similar APIs to the Android MediaPlayer and VideoView that uses the ExoPlayer as a backing when possible, otherwise the default Android MediaPlayer and VideoView are used.
The ExoPlayer is only supported on devices that pass the compatibility Test Suite and that are JellyBean (API 16) or greater. The ExoPlayer provides additional support for streaming (HLS, DASH, etc.) and full HD (1080p +)
The ExoMedia website can be found here
The ExoMedia documentation website can be found on the website linked above or here
The latest AAR (Android Archive) files can be downloaded from JCenter
Or included in your gradle dependencies
repositories {
jcenter();
}
dependencies {
compile 'com.devbrackets.android:exomedia:3.1.1'
}
The EMVideoView (EM for ExoMedia) can be added in your layout files like any other Android view.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:EMVideoView="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.devbrackets.android.exomedia.ui.widget.EMVideoView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
EMVideoView:useDefaultControls="true"/>
</RelativeLayout>
While in your Activity or Fragment you treat it like a standard Android VideoView
private void setupVideoView() {
EMVideoView emVideoView = (EMVideoView)findViewById(R.id.video_view);
emVideoView.setOnPreparedListener(this);
//For now we just picked an arbitrary item to play. More can be found at
//https://archive.org/details/more_animation
emVideoView.setVideoURI(Uri.parse("https://archive.org/download/Popeye_forPresident/Popeye_forPresident_512kb.mp4"));
}
@Override
public void onPrepared() {
//Starts the video playback as soon as it is ready
emVideoView.start();
}
Copyright 2017 Brian Wernick
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Uses Material Design icons licensed under Apache 2.0