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.slashrootv200:exo-player-fragment:0.0.3'
}
dependencies {
implementation("com.github.slashrootv200:exo-player-fragment:0.0.3")
}
<dependency>
<groupId>com.github.slashrootv200</groupId>
<artifactId>exo-player-fragment</artifactId>
<version>0.0.3</version>
</dependency>
libraryDependencies += "com.github.slashrootv200" % "exo-player-fragment" % "0.0.3"
:dependencies [[com.github.slashrootv200/exo-player-fragment "0.0.3"]]
Library which contains ExoPlayer(https://github.com/google/ExoPlayer) inside a Fragment, so that it is easier to use on an Activity
The Fragment use the code from the demo player provided in https://github.com/google/ExoPlayer repository.
Note: The ExoPlayerFragmanet
extends support Fragment.java and therefore requires support FragmentManager.java
<dependency>
<groupId>com.github.slashrootv200</groupId>
<artifactId>exo-player-fragment-lib</artifactId>
<version>0.0.3</version>
<type>pom</type>
</dependency>
compile 'com.github.slashrootv200:exo-player-fragment-lib:0.0.3'
If you don't want the track selection for video, audio, text to be shown on the ExoPlayerFragment then override these boolean resources
res/values/{some_file_name_of_your_choice}.xml
<bool name="exo_fragment_lib_show_video_selector">true</bool>
<bool name="exo_fragment_lib_show_audio_selector">false</bool>
<bool name="exo_fragment_lib_show_text_selector">false</bool>
By default all the values are true so you will see all the three choices if they are available.
Example: In onCreate of an Activity.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
Uri videoUri = Uri.parse("http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes.m3u8");
String videoTitle = "Sample Video";
mExoPlayerFragment = ExoPlayerFragment.newInstance(videoUri, videoTitle);
getSupportFragmentManager().beginTransaction()
.add(R.id.main_container, mExoPlayerFragment, ExoPlayerFragment.TAG)
.commit();
}
}
If you do not have any Base Activity class then you can also use BaseExoPlayerActivity.java
as base class for your Activity which contains the Exo player. Please refer the demo app in the git repository for more information.
ExoPlayerFragment
can be instantiated in using one of the four static methods:
1. ExoPlayerFragment.newInstance(Uri uri)
-> uri = video uri
1. ExoPlayerFragment.newInstance(Uri uri, String videoTitle)
-> videoTitle = video title
1. ExoPlayerFragment.newInstance(Uri uri, int dialogTheme)
-> dialogTheme = theme resource Id for the dialogs created for track selection
1. ExoPlayerFragment.newInstance(Uri uri, String videoTitle, int dialogTheme)
-> videoTitle = video title and dialogTheme = theme resource Id for the dialogs created for track selection
Instead of passing int dialogTheme
you can also override theme by name ExoPlayerFragmentTrackSelectionDialogTheme
in your application's styles.xml
to override the dialog theme