Giter Site home page Giter Site logo

hamidrezaamz / magicalexoplayer Goto Github PK

View Code? Open in Web Editor NEW
337.0 11.0 77.0 445 KB

The Easiest Way To Play/Stream Video And Audio Using Google ExoPlayer In Your Android Application

License: MIT License

Java 4.89% Kotlin 95.11%
android androidx exoplayer videoplayer mp4 hls dash video player mobile

magicalexoplayer's Introduction

GitHub API

MagicalExoPlayer

The Easiest Way To Play Video Using ExoPlayer In Your Android Application. Add Dependencies Into Your Gadle File, Sync Your Project And Then Just Pass Your Url Or Local Video Address To The Player. MagicalExoPlayer Support MP4, HLS, DASH And MP3.

mock_up_and_exo_player_2

Getting Started

These instructions will help you to use this library inside your projects

Prerequisites

This library was built with androidX, so you should migrate into androidX to use this library with out any problem. For migration you can use Migrating to AndroidX

Installing

Step 1. Add the JitPack repository to your build file, Add it in your root build.gradle at the end of repositories:

allprojects {
        repositories {
            maven { url 'https://jitpack.io' }
        }
    }

Step 2. Add the dependency

dependencies {
    implementation 'com.github.HamidrezaAmz:MagicalExoPlayer:X.X.X'
}

Here we go for implementation

Add player view into your XML

<com.potyvideo.library.AndExoPlayerView
        android:id="@+id/andExoPlayerView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

Refrence to custom-view inside your activity or fragment (I use butterknife), Or you can use findViewById()

 @BindView(R.id.andExoPlayerView)
 AndExoPlayerView andExoPlayerView;

Or

 AndExoPlayerView andExoPlayerView = findViewById(R.id.andExoPlayerView);

Implementation Example

 andExoPlayerView.setSource("URL OR FILE ADDRESS");

Custom Attributes

Command Description
andexo_resize_mode Type Of Video Player Size, you can pass Fill,Fit,Zoom
andexo_full_screen Show FullScreen Toggle Button, you can Pass True,False
andexo_play_when_ready Player Start Playing On Stream Is Ready True,False
andexo_aspect_ratio In Order To Get The Desired Playerr Size, You Can Pass The Aspect Ratios You Need ASPECT_1_1, ASPECT_16_9, ASPECT_4_3, ASPECT_MATCH, ASPECT_MP3
andexo_show_controller Show Or Hide Player Controller True,False
andexo_loop Play video with loop modes Infinite,Finite

XML With Custom Attrs.

<com.potyvideo.library.AndExoPlayerView
        android:id="@+id/andExoPlayerView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:andexo_aspect_ratio="aspect_16_9"
        app:andexo_full_screen="true"
        app:andexo_play_when_ready="true"
        app:andexo_show_controller="true"
        app:andexo_resize_mode="Fit" />

TIP

  • If you wan to support full screen, please add this config into your activity in manifest.xml
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode"

For example your activity with be something like this

<activity
      android:name=".MainActivity"
      android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode">
      <intent-filter>
          <action android:name="android.intent.action.MAIN" />

          <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
</activity>
  • If you want to pass custom headers over your stream url, you can just pass them as a hashmap like this:
  HashMap<String , String> extraHeaders = new HashMap<>();
  extraHeaders.put("foo","bar");
  andExoPlayerView.setSource("STREAM_URL", extraHeaders);

Other Libraries


❤️ Support My Projects

However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it. ☕ 🍔 🍟 🍎

  • Starring: You may give a star or share the projects you like.

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.