Giter Site home page Giter Site logo

jaumrato / exo-player-fragment Goto Github PK

View Code? Open in Web Editor NEW

This project forked from slashrootv200/exo-player-fragment

0.0 1.0 0.0 169 KB

Library which contains Exo Player fragment, so that it is easier to use on an Activity

License: Apache License 2.0

Java 100.00%

exo-player-fragment's Introduction

exo-player-fragment

Download

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

Download

maven

<dependency>
  <groupId>com.github.slashrootv200</groupId>
  <artifactId>exo-player-fragment-lib</artifactId>
  <version>0.0.3</version>
  <type>pom</type>
</dependency>

gradle

compile 'com.github.slashrootv200:exo-player-fragment-lib:0.0.3'

Configuration

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.

Usage

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
  2. ExoPlayerFragment.newInstance(Uri uri, String videoTitle)-> videoTitle = video title
  3. ExoPlayerFragment.newInstance(Uri uri, int dialogTheme)-> dialogTheme = theme resource Id for the dialogs created for track selection
  4. 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

exo-player-fragment's People

Contributors

pratap-c1 avatar slashrootv200 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.