An extensible media player for Android

Overview

ExoPlayer

ExoPlayer is an application level media player for Android. It provides an alternative to Android’s MediaPlayer API for playing audio and video both locally and over the Internet. ExoPlayer supports features not currently supported by Android’s MediaPlayer API, including DASH and SmoothStreaming adaptive playbacks. Unlike the MediaPlayer API, ExoPlayer is easy to customize and extend, and can be updated through Play Store application updates.

Documentation

Using ExoPlayer

ExoPlayer modules can be obtained from JCenter. It's also possible to clone the repository and depend on the modules locally.

From JCenter

1. Add repositories

The easiest way to get started using ExoPlayer is to add it as a gradle dependency. You need to make sure you have the Google and JCenter repositories included in the build.gradle file in the root of your project:

repositories {
    google()
    jcenter()
}

2. Add ExoPlayer module dependencies

Next add a dependency in the build.gradle file of your app module. The following will add a dependency to the full library:

implementation 'com.google.android.exoplayer:exoplayer:2.X.X'

where 2.X.X is your preferred version.

As an alternative to the full library, you can depend on only the library modules that you actually need. For example the following will add dependencies on the Core, DASH and UI library modules, as might be required for an app that plays DASH content:

implementation 'com.google.android.exoplayer:exoplayer-core:2.X.X'
implementation 'com.google.android.exoplayer:exoplayer-dash:2.X.X'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.X.X'

The available library modules are listed below. Adding a dependency to the full library is equivalent to adding dependencies on all of the library modules individually.

  • exoplayer-core: Core functionality (required).
  • exoplayer-dash: Support for DASH content.
  • exoplayer-hls: Support for HLS content.
  • exoplayer-smoothstreaming: Support for SmoothStreaming content.
  • exoplayer-ui: UI components and resources for use with ExoPlayer.

In addition to library modules, ExoPlayer has multiple extension modules that depend on external libraries to provide additional functionality. Some extensions are available from JCenter, whereas others must be built manually. Browse the extensions directory and their individual READMEs for details.

More information on the library and extension modules that are available from JCenter can be found on Bintray.

3. Turn on Java 8 support

If not enabled already, you also need to turn on Java 8 support in all build.gradle files depending on ExoPlayer, by adding the following to the android section:

compileOptions {
  targetCompatibility JavaVersion.VERSION_1_8
}

Locally

Cloning the repository and depending on the modules locally is required when using some ExoPlayer extension modules. It's also a suitable approach if you want to make local changes to ExoPlayer, or if you want to use a development branch.

First, clone the repository into a local directory and checkout the desired branch:

git clone https://github.com/google/ExoPlayer.git
cd ExoPlayer
git checkout release-v2

Next, add the following to your project's settings.gradle file, replacing path/to/exoplayer with the path to your local copy:

gradle.ext.exoplayerRoot = 'path/to/exoplayer'
gradle.ext.exoplayerModulePrefix = 'exoplayer-'
apply from: new File(gradle.ext.exoplayerRoot, 'core_settings.gradle')

You should now see the ExoPlayer modules appear as part of your project. You can depend on them as you would on any other local module, for example:

implementation project(':exoplayer-library-core')
implementation project(':exoplayer-library-dash')
implementation project(':exoplayer-library-ui')

Developing ExoPlayer

Project branches

  • Development work happens on the dev-v2 branch. Pull requests should normally be made to this branch.
  • The release-v2 branch holds the most recent release.

Using Android Studio

To develop ExoPlayer using Android Studio, simply open the ExoPlayer project in the root directory of the repository.

Comments
  • Add RTSP support

    Add RTSP support

    This is our first public release of our in-house RTSP Mediasource, we have to rewrite it several times to make it useful for a wider audience and more easily maintainable and extensible. It currently supports:

    • RTSP 1.0 (RFC2326) - with Basic and Digest authentication in standard URL encoding (some devices use URL parameters to encode user/password info)
    • SDP (RFC4566)
    • MP2T over UDP
    • RTP (RFC3550)
    • RTP payloads:
      • MP2T
      • H264 (RFC6184) - single NAL Unit and Non-Interleaved modes
      • AAC (RFC3640) - LR and HR bitrates, simple, multiple and fragmented AAC frames (interleaved not implemented)
      • AC3 (RFC4184)
      • G711.1 (RFC5391) - R1, R2A, R2B and R3 modes (untested)
      • G711.0 (RFC7655)

    We are working to integrate Server Trick Modes and asynchronous notifications, but we have to clarify the best way to control a push media source (we need to modify explayerImpInternal to communicate the player state to the media source - pause - and the media source to inform that some events had ocurred - end of stream reached, begin of stream reached, ...) with the Exoplayer lead developers in the meantime the trick modes have to be implemented outside the library.

    cla: yes 
    opened by tresvecesseis 269
  • RTSP support

    RTSP support

    http://developer.android.com/guide/appendix/media-formats.html says that RTSP is supported but when trying to access an RTSP stream the MediaExtractor fails.

    enhancement 
    opened by kjeremy 98
  • Generalize/enhance persistent caching functionality

    Generalize/enhance persistent caching functionality

    ExoCache is designed specifically for DASH implementations where every request can be in the form of a bounded range request (which in practice means single-segment on-demand streams containing sidx boxes). It doesn't work for anything else (DASH where streams are segmented in the manifest, SmoothStreaming, HLS, ExtractorSampleSource). There are three things to fix:

    1. We don't support unbounded range requests. This is because the cache currently has no concept of the length of a piece of data. If we have a file in the cache with byte range [0-1000], and make a request for range [0-*], we currently don't know what to do after we've return the first 1000 bytes from the cache. We don't want to make an unconditional request to the network starting at offset=1000 because it's inefficient, wont work in the offline case, and because the server may return a 416 (unsatisfiable byte-range) in the case that the content really is 1000 bytes long, which would be awkward to handle.
    2. It's probably more common for servers that are configured to serve every chunk from a separate URL to not support range requests. We may need the cache to support a "request the whole chunk or nothing from the upstream source" mode for this use case. I'm not sure how we'd decide when to turn it on. Awkward.
    3. The cache currently indexes: contentId->Tree[byte-range->file]. For chunks that are requested from different URLs, we need the Tree to be indexed by chunk-index+byte-range, or perhaps just chunk-index depending on the answer to (2).
    enhancement 
    opened by ojw28 92
  • Offlining video with encryption

    Offlining video with encryption

    I'm not using the template because I'm not filing a bug report or reporting an issue, bur rather requesting a wiki, sample, documentation, or some form of direction

    First, thanks to all the contributors for the time and work they'v invested, this is a great product and I appreciate what's involved in maintaining it.

    This isn't a bug report so much of a request for direction. The question seems common: playing non-HLS (offline) encrypted video.

    
https://github.com/google/ExoPlayer/issues/2420 https://github.com/google/ExoPlayer/issues/1964 https://github.com/google/ExoPlayer/issues/1720 https://github.com/google/ExoPlayer/issues/1586 https://github.com/google/ExoPlayer/issues/1241 https://github.com/google/ExoPlayer/issues/1091

    I think a simple MVP would go a long way. Hopefully this wouldn't take too long for someone who knows what they're doing.

    In our case, we allow users to download a video to internal or external storage, but need to encrypt it so that it's not distributed.

    Last year, using ExoPlayer 1, I was able to do this successfully with the RC4 algorithm and a simple CipherInputStream in a custom DataSource. However, seeking was extremely slow (5, 10, 20 seconds), IIUC because the encrypted stream needed to be read from the beginning of the file.

    Fast forward to this month, using ExoPlayer 1 again (initially; I quickly moved to ExoPlayer 2), I was able to modify the bytes in the input and output buffers successfully, so could make the content "non-playable" by flipping bits and grunging, but of course this is not secure at all.

    In exploring other strategies, it looks like some modes allow random read access (http://libeasy.alwaysdata.net/network/#server), so I moved to AES/CTR/NoPadding (and ExoPlayer 2), which is the same algorithm used by AesCipherDataSource. All of my subsequent attempts have used this algorithm.

    My first attempt was to use the AesCipherDataSource with my encrypted content. I encrypted the file "in-app" (using standard stream methods) and copied it to assets. While the IV was different (since AesFlushingCipher makes its own IV in the constructor), the key was the same, and to my understanding it should have been able to decrypt, but it failed with "None of the available extractors" (which I've come to learn usually means the decryption failed). I was hopeful here and am curious why this failed. I'm confident the encryption didn't fail, because I was able to decrypt and read it with alternate approaches (details follow; although none worked perfectly, I was able to consistently get at least playback), and decrypting the same file immediately afterward and playing it with standard DataSource also worked.

    I then tried modifying both AesFlushingCipher and AesCipherDataSource to allow me to pass in my own cipher instance. This got closer - I had playback but seeking will throw an error - IIRC it would always error when seeking to a point previous to last played, and sometimes when seeking otherwise (TBH this was many attempts back and I might be misremembering the specifics of the failure, but I did fail).

    Returning to the original strategy of using a CipherInputStream (basically copying AssetDataSource with a CipherInputStream around it), again provided close-but-not-quite results - playback was fine but seeking would sometimes throw errors. If you scrubbed "gently" (gave it plenty of time to "warm up", only moved forward in small increments), it would work reasonably well, but seeking immediately or seeking backwards would almost always throw an error: "Top bit not zero".

    FWIW I'm using the same sample video I used for the RC4 version last year. During those investigations, I tried several different files and believe the inconsistency is not because of the file (an 11MB mp4).

    Would it be possible to provide a working example of a DataSource reading encrypted local files? I'd really appreciate any insight or direction.

    Thanks again.

    question 
    opened by moagrius 65
  • nVidia Shield: HDR Mode not triggered for cropped content

    nVidia Shield: HDR Mode not triggered for cropped content

    Issue description

    Videos that are HDR but have been cropped to non-full resolution (e.g. 2.35 aspect) are not triggering the HDR mode on the TV when played. Items that are not cropped do turn on HDR properly.

    Reproduction steps

    Play the following video on an HDR capable set.

    Link to test content

    https://drive.google.com/file/d/1uQGkgw8fkkrMFyKQ4fl9aOvi6RuhLQHX/view

    Version of ExoPlayer being used

    2.9.1

    Device(s) and version(s) of Android being used

    Tested on NVidia Shield running Android 8.0

    A full bug report captured from the device

    Unable to capture report at this time.

    bug: device specific 
    opened by ebr11 61
  • Difference in video quality compared to mediaplayer

    Difference in video quality compared to mediaplayer

    Issue description

    Hello We are using Exoplayer on our application. We have noticed that there is a difference on video quality between Exolplayer and Mediaplayer. The picture quality is better on Mediaplayer and the video plays smoothly (the colors seem to be different). On the other hand, picture on Exoplayer is not so clear and video freezes time after time. We are testing the same streams in both players

    Version of ExoPlayer being used

    The version of exoplayer is 2.7.1

    Device(s) and version(s) of Android being used

    We have tested on different devices, mainly in Android 4.4.2 STB

    A full bug report captured from the device

    need more info bug: device specific 
    opened by loredana2314 61
  • Implement full offline support for DASH/HLS/SS/Misc

    Implement full offline support for DASH/HLS/SS/Misc

    Hi,

    Is download and/or progressive download of adaptive streaming presentations a feature that is planned for ExoPlayer?

    Note I am referring to 'up front' acquisition of the content rather than local HTTP caching.

    Thanks.

    enhancement 
    opened by ghost 61
  • Implement seeking within HLS moving live window in ExoPlayer and its demo app

    Implement seeking within HLS moving live window in ExoPlayer and its demo app

    The server may keep old chunks available to the streaming clients so that they can rewind the video, for example, to 10 minutes before the live position. Imagine you missed the start of a live tv-show or you were interrupted and missed a part, so you want to rewind it. There are two main, common cases here, the live playlist received by the clients can be of a short or a long duration.

    1. Often CDNs will give you a short playlist with 3-10 chunks, for a playlist duration of 2-3 minutes or less. In this case seeking inside the playlist is not very useful. Instead you would make a request to the CDN for a new playlist at a different position, for example live head - 20 minutes. The NASA TV public live stream is an example of this approach, http://www.nasa.gov/multimedia/nasatv/NTV-Public-IPS.m3u8

    2. The second case, that this issue covers, is where you get a long playlist, for example 120 chunks, or 1 hour, from the server. In this case seeking within the playlist is desirable. Because the server is continuously deleting old chunks (and writing new ones), you have a moving live window of a certain fixed size in seconds. The player/library must not request chunks outside of the window, as that will give an HTTP error (404). The seekbar must take the moving live window into consideration. While watching the stream, the seekbar should be in the same position, e.g. 10 minutes before live head. The playlist must be refetched when reaching the end of the playlist, or when the user seeks to the end of the playlist. The player UI could for example display "live" as the duration and "-10:00" for the current position when the user has rewinded the live video 10 minutes.

    Please let me know if you would like a public sample stream for case (2).

    enhancement 
    opened by perchrh 59
  • MediaCodec initialisation fails.

    MediaCodec initialisation fails.

    Issue description

    On certain devices that use OMX.MTK.VIDEO.DECODER.AVC decoder, on DRM content ONLY we receive the below error.

    Reproduction steps

    • Initialise SimpleExoPlayer
    • Prepare MediaSource with drm.
    • Note, that in prepare step, we are NOT attaching SimpleExoplayerView to view hierarchy, and only doing so, after player state READY received.
    • Get the crash, immediately after prepare() called.

    Link to test content

    "uri": "https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears.mpd" "drm_license_url": "https://proxy.uat.widevine.com/proxy?provider=widevine_test"

    Version of ExoPlayer being used

    We can see this issue reproduced on Exoplayer 2.5.0 and above (including 2.6.1) Previous Exoplayer versions work as expected.

    Device(s) and version(s) of Android being used

    Device - Meizu M5C, Lenovo K4 and Moto C+ (all of them with OMX.MTK.VIDEO.DECODER.AVC) Android version - 6.0

    ### A full bug report captured from the device

    com.google.android.exoplayer2.ExoPlaybackException
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.throwDecoderInitError(MediaCodecRenderer.java:418)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodec(MediaCodecRenderer.java:405)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:839)
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:455)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:536)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:560)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:306)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:207)
        at android.os.HandlerThread.run(HandlerThread.java:61)
     Caused by: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.MTK.VIDEO.DECODER.AVC, Format(1, null, video/avc, 720
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodec(MediaCodecRenderer.java:405) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:839) 
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:455) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:536) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:560) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:306) 
        at android.os.Handler.dispatchMessage(Handler.java:107) 
        at android.os.Looper.loop(Looper.java:207) 
        at android.os.HandlerThread.run(HandlerThread.java:61) 
     Caused by: android.media.MediaCodec$CodecException: start failed
        at android.media.MediaCodec.native_start(Native Method)
        at android.media.MediaCodec.start(MediaCodec.java:1898)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodec(MediaCodecRenderer.java:397)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:839) 
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:455) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:536) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:560) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:306) 
        at android.os.Handler.dispatchMessage(Handler.java:107) 
        at android.os.Looper.loop(Looper.java:207) 
        at android.os.HandlerThread.run(HandlerThread.java:61) 
    
    bug: device specific 
    opened by AntonAFA 58
  • Offline DRM protection

    Offline DRM protection

    Hi, Any news on offline DRM protection? Is it possible to decrypt and play a widevine protected movie that is stored on the phone with no internet access?

    question 
    opened by sarahachem 58
  • Rotation issue

    Rotation issue

    1. record a video in portrait using native android camcorder (nexus 4)
    2. play it using native player. Rotation is correct
    3. play it using demo app (SimplePlayerActivity). Video is rotated.

    Example of the test video: https://drive.google.com/file/d/0B9_5dr6in8cWcmlGZlJrSlhHS1U/view?usp=sharing

    Metadata of the mp4 contains a property: Rotation : 90° but it's ignored by the exo player.

    bug: in platform 
    opened by emakovsky 57
  • Expect exoplayer could continue to play although the meta of video is invalid.

    Expect exoplayer could continue to play although the meta of video is invalid.

    [REQUIRED] Use case description

    Some videos have the invalid meta block, for example: image this video is only 5MB. The Audio and Video trackers are valid.

    Exoplayer can't play this video, it would throw InvalidResponseCodeException: Response Code 416. However, chrome, desktop and ffplay can play the video. I'm not good at media development, and for the protection of user privacy, I can't provide the video or other detailed message.

    Proposed solution

    Is it possible that skip the throw-exception step that read and parse the unnecessary data, so that exoplayer can continue to read and parse the next data, finally play the video successfully.

    #3123

    enhancement needs triage 
    opened by joechan-cq 0
  • Unable to play H264 50 tps Video

    Unable to play H264 50 tps Video

    I am trying to play a HLS manifest live stream which is playable in VLC for Android. Its also playable in browser with just hls.js. Stream audio is MPEG-L2 and Video is h264. Attached here a sample ts segment for inspection. 53-05280.zip

    FFMPEG probe:

    Program 0 Metadata: variant_bitrate : 4030000 Stream #0:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 50 tbc Metadata: variant_bitrate : 4030000 Stream #0:1: Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 96 kb/s Metadata: variant_bitrate : 4030000

    Now, I am trying to play same HLS playlist with exoplayer demo. Exoplayer shows a black screen without any audio for the same stream. If I select only the audio I can hear audio just fine. I even tried with the NDK compiled FFMPEG extensions even though its just for audio and audio is playing fine. With extension decoders preferred it behaves exactly same.

    Exoplayer does not give an error and no error logs etc.

    I am not sure if I am missing any special configuration as audio and video codecs seem all supported.

    If anyone interested I can generate a time window valid HLS stream url for testing. Thanks a ton for the devs of this project.

    question needs triage 
    opened by marufbd 0
  • Play some hls videos frozen in the first frame

    Play some hls videos frozen in the first frame

    Only the first frame can be displayed and then stopped my video url:https://v-st1-http-play.cmcconenet.com:8443/live/live_100757778_1/index.m3u8?token=eyJrZXkiOjI4MzQzLCJzaWduIjoiQkJocmZzdnJtaFlvbmctWDFSLTJWSTRXRHA4MU0yajJzcEdKREJ4SjhCZTVWRjdHT29KandWODgxZ2xpRVV2RUppMFlpZHdyXzQwTXkybkFyb2x1RUVsVVdacDJEOUphRHE5WkpBUVN3QVZQaE5tbjUzay1KeXFhbnhLR0N1ZnIyWEplcmNtXzBBMWFheGJocWRqdDBRd1dueUw4Y2xJYkdqd24waHU1VGFGSXAzMkV1LWJGUExqM1pHRDk0LXpYVzR2Sl9xMkVqZU40cjBVS1phVk9hdyJ9 log: 2023-01-09 09:54:27.416 26464-27747/com.heking.zplayer.demo I/CCodecConfig: query failed after returning 16 values (BAD_INDEX) 2023-01-09 09:54:27.416 26464-27747/com.heking.zplayer.demo D/CCodecConfig: c2 config is Dict { c2::u32 coded.aac-packaging.value = 0 c2::u32 coded.bitrate.value = 64000 c2::u32 coded.pl.level = 0 c2::u32 coded.pl.profile = 8192 c2::float coding.drc.attenuation-factor.value = 1 c2::float coding.drc.boost-factor.value = 1 c2::i32 coding.drc.compression-mode.value = 3 c2::i32 coding.drc.effect-type.value = 3 c2::float coding.drc.encoded-level.value = 0.25 c2::float coding.drc.reference-level.value = -16 c2::u32 input.buffers.max-size.value = 8192 c2::u32 input.delay.value = 0 string input.media-type.value = "audio/mp4a-latm" c2::u32 output.delay.value = 2 string output.media-type.value = "audio/raw" c2::u32 raw.channel-count.value = 1 c2::u32 raw.sample-rate.value = 44100 } 2023-01-09 09:54:27.418 26464-27747/com.heking.zplayer.demo D/CCodecConfig: c2 config is Dict { c2::u32 coded.aac-packaging.value = 0 c2::u32 coded.bitrate.value = 64000 c2::u32 coded.pl.level = 0 c2::u32 coded.pl.profile = 8192 c2::float coding.drc.attenuation-factor.value = 1 c2::float coding.drc.boost-factor.value = 1 c2::i32 coding.drc.compression-mode.value = 3 c2::i32 coding.drc.effect-type.value = 3 c2::float coding.drc.encoded-level.value = 0.25 c2::float coding.drc.reference-level.value = -16 c2::u32 input.buffers.max-size.value = 8192 c2::u32 input.delay.value = 0 string input.media-type.value = "audio/mp4a-latm" c2::u32 output.delay.value = 2 string output.media-type.value = "audio/raw" c2::u32 raw.channel-count.value = 1 c2::u32 raw.sample-rate.value = 8000 } 2023-01-09 09:54:27.418 26464-27747/com.heking.zplayer.demo W/Codec2Client: query -- param skipped: index = 1107298332. 2023-01-09 09:54:27.418 26464-27747/com.heking.zplayer.demo D/CCodec: setup formats input: AMessage(what = 0x00000000) = { int32_t channel-count = 1 int32_t level = 0 int32_t max-input-size = 8192 string mime = "audio/mp4a-latm" int32_t profile = 2 int32_t sample-rate = 8000 } and output: AMessage(what = 0x00000000) = { int32_t channel-count = 1 string mime = "audio/raw" int32_t sample-rate = 8000 }

    question needs triage 
    opened by zhougan870822 2
  • Award-winning Exoplayer and unity ads video.

    Award-winning Exoplayer and unity ads video.

    Guys, I added the unity ads code in my exoplayer player file and the ad runs well, the problem is that after closing the ad, the movie does not play. If I remove the unity ads ad code, the movie plays normally. Could someone help me to run the normal movie after closing the ad? Follow the video showing. Thank you all. https://drive.google.com/file/d/1KSuq5rACBxlCRnRp9ca_XVTd45h9V7KD/view?usp=share_link This is the code for PlayerActivity.java

    package com.cineday.box.view;
    
    import static android.view.View.VISIBLE;
    
    import androidx.recyclerview.widget.LinearLayoutManager;
    import androidx.recyclerview.widget.RecyclerView;
    
    import android.app.Activity;
    import android.app.AlertDialog;
    import android.content.Context;
    import android.content.Intent;
    import android.media.AudioManager;
    import android.media.session.MediaSession;
    import android.net.Uri;
    import android.os.Bundle;
    import android.os.Handler;
    import android.os.PowerManager;
    import android.util.Log;
    import android.view.KeyEvent;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.widget.Button;
    import android.widget.ImageButton;
    import android.widget.ImageView;
    import android.widget.ProgressBar;
    import android.widget.RelativeLayout;
    import android.widget.TextView;
    import android.widget.Toast;
    
    
    import com.cineday.box.AppConfig;
    import com.google.android.exoplayer2.C;
    import com.google.android.exoplayer2.ExoPlayerFactory;
    import com.google.android.exoplayer2.Format;
    import com.google.android.exoplayer2.Player;
    import com.google.android.exoplayer2.SimpleExoPlayer;
    import com.google.android.exoplayer2.ext.rtmp.RtmpDataSourceFactory;
    import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
    import com.google.android.exoplayer2.extractor.ExtractorsFactory;
    import com.google.android.exoplayer2.source.ExtractorMediaSource;
    import com.google.android.exoplayer2.source.MediaSource;
    import com.google.android.exoplayer2.source.MergingMediaSource;
    import com.google.android.exoplayer2.source.SingleSampleMediaSource;
    import com.google.android.exoplayer2.source.hls.HlsMediaSource;
    import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
    import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
    import com.google.android.exoplayer2.trackselection.TrackSelection;
    import com.google.android.exoplayer2.trackselection.TrackSelector;
    import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
    import com.google.android.exoplayer2.ui.PlayerControlView;
    import com.google.android.exoplayer2.ui.PlayerView;
    import com.google.android.exoplayer2.upstream.BandwidthMeter;
    import com.google.android.exoplayer2.upstream.DataSource;
    import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
    import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
    import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
    import com.google.android.exoplayer2.util.MimeTypes;
    import com.google.android.exoplayer2.util.Util;
    import com.cineday.box.R;
    import com.cineday.box.database.DatabaseHelper;
    import com.cineday.box.model.PlaybackModel;
    import com.cineday.box.model.Video;
    import com.cineday.box.model.movieDetails.Subtitle;
    import com.cineday.box.utils.ToastMsg;
    import com.cineday.box.view.adapter.ServerAdapter;
    import com.cineday.box.view.adapter.SubtitleListAdapter;
    import com.squareup.picasso.Picasso;
    import com.unity3d.ads.IUnityAdsInitializationListener;
    import com.unity3d.ads.IUnityAdsLoadListener;
    import com.unity3d.ads.IUnityAdsShowListener;
    import com.unity3d.ads.UnityAds;
    import com.unity3d.ads.UnityAdsShowOptions;
    import android.app.Activity;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.List;
    import java.util.concurrent.TimeUnit;
    
    public class PlayerActivity extends Activity implements IUnityAdsInitializationListener {
        Context context = this;
        private static final String TAG = "PlayerActivity";
        private static final String CLASS_NAME = "com.cineday.box.ui.activity.PlayerActivity";
        private PlayerView exoPlayerView;
        private SimpleExoPlayer player;
        private RelativeLayout rootLayout;
        private MediaSource mediaSource;
        private boolean isPlaying;
        private List<Video> videos = new ArrayList<>();
        private Video video = null;
        private String url = "";
        private String videoType = "";
        private String category = "";
        private int visible;
        private ImageButton serverButton, fastForwardButton, subtitleButton;
        private TextView movieTitleTV, movieDescriptionTV;
        private ImageView posterImageView, posterImageViewForTV;
        private RelativeLayout seekBarLayout;
        private TextView liveTvTextInController;
        private ProgressBar progressBar;
        private PowerManager.WakeLock wakeLock;
        private MediaSession session;
    
        private long mChannelId;
        private long mStartingPosition;
        private PlaybackModel model;
    
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_player);
    
            { //unityads
                IUnityAdsLoadListener loadListener = new IUnityAdsLoadListener() {
                    @Override
                    public void onUnityAdsAdLoaded(String placementId) {
                        UnityAds.show(PlayerActivity.this, AppConfig.Unity_rewardedVideo_ID, new UnityAdsShowOptions(), new IUnityAdsShowListener() {
                            @Override
                            public void onUnityAdsShowFailure(String placementId, UnityAds.UnityAdsShowError error, String message) {
                                Log.e("UnityAdsExample", "Unity Ads failed to load ad for " + placementId + " with error: [" + error + "] " + message);
                            }
    
    
                            @Override
                            public void onUnityAdsShowStart(String placementId) {
                                Log.v("UnityAdsExample", "onUnityAdsShowStart: " + placementId);
                            }
    
                            @Override
                            public void onUnityAdsShowClick(String placementId) {
                                Log.v("UnityAdsExample", "onUnityAdsShowClick: " + placementId);
                            }
    
                            @Override
                            public void onUnityAdsShowComplete(String placementId, UnityAds.UnityAdsShowCompletionState state) {
                                Log.v("UnityAdsExample", "onUnityAdsShowComplete: " + placementId);
                                if (state.equals(UnityAds.UnityAdsShowCompletionState.COMPLETED)) {
                                    // Reward the user for watching the ad to completion
                                } else {
                                    // Do not reward the user for skipping the ad
                                }
                            }
                        });
                    }
    
                    @Override
                    public void onUnityAdsFailedToLoad(String placementId, UnityAds.UnityAdsLoadError error, String message) {
    
    
                    }
                };
                UnityAds.initialize (this, AppConfig.Unity_Game_ID, AppConfig.unity_ad_testMode);
                UnityAds.load(AppConfig.Unity_rewardedVideo_ID, loadListener);
            }
    
            mChannelId = getIntent().getLongExtra(VideoPlaybackActivity.EXTRA_CHANNEL_ID, -1L);
            mStartingPosition = getIntent().getLongExtra(VideoPlaybackActivity.EXTRA_POSITION, -1L);
    
            model = (PlaybackModel) getIntent().getSerializableExtra(VideoPlaybackActivity.EXTRA_VIDEO);
    
    
            assert model != null;
            url = model.getVideoUrl();
            videoType = model.getVideoType();
            category = model.getCategory();
            if (model.getVideo() != null)
                video = model.getVideo();
            if (model.getCategory().equals("movie") && mChannelId > -1L && model.getIsPaid().equals("1")) {
                //Paid Content from Channel
                //check user has subscription or not
                //if not, send user to VideoDetailsActivity
                DatabaseHelper db = new DatabaseHelper(PlayerActivity.this);
                final String status = db.getActiveStatusData() != null ? db.getActiveStatusData().getStatus() : "inactive";
                if (!status.equals("active")) {
                    Intent intent = new Intent(PlayerActivity.this, VideoDetailsActivity.class);
                    intent.putExtra("type", model.getCategory());
                    intent.putExtra("id", model.getMovieId());
                    intent.putExtra("thumbImage", model.getCardImageUrl());
                    startActivity(intent, null);
                    finish();
                }
            }
    
            intiViews();
            initVideoPlayer(url, videoType);
    
        }
    
        private void intiViews() {
            progressBar = findViewById(R.id.progress_bar);
            exoPlayerView = findViewById(R.id.player_view);
            rootLayout = findViewById(R.id.root_layout);
            movieTitleTV = findViewById(R.id.movie_title);
            movieDescriptionTV = findViewById(R.id.movie_description);
            posterImageView = findViewById(R.id.poster_image_view);
            posterImageViewForTV = findViewById(R.id.poster_image_view_for_tv);
            serverButton = findViewById(R.id.img_server);
            subtitleButton = findViewById(R.id.img_subtitle);
            fastForwardButton = findViewById(R.id.exo_ffwd);
            liveTvTextInController = findViewById(R.id.live_tv);
            seekBarLayout = findViewById(R.id.seekbar_layout);
            if (category.equalsIgnoreCase("tv")) {
                serverButton.setVisibility(View.GONE);
                subtitleButton.setVisibility(View.GONE);
                //seekBarLayout.setVisibility(View.GONE);
                fastForwardButton.setVisibility(View.GONE);
                liveTvTextInController.setVisibility(View.VISIBLE);
                posterImageView.setVisibility(View.GONE);
                posterImageViewForTV.setVisibility(VISIBLE);
                seekBarLayout.setVisibility(View.GONE);
            }
    
            if (category.equalsIgnoreCase("tvseries")) {
                serverButton.setVisibility(View.GONE);
                //hide subtitle button if there is no subtitle
                if (video != null) {
                    if (video.getSubtitle().isEmpty()) {
                        subtitleButton.setVisibility(View.GONE);
                    }
                } else {
                    subtitleButton.setVisibility(View.GONE);
                }
            }
    
            if (category.equalsIgnoreCase("movie")) {
                if (model.getVideoList() != null)
                    videos.clear();
                videos = model.getVideoList();
                //hide subtitle button if there is no subtitle
                if (video != null) {
                    if (video.getSubtitle().isEmpty()) {
                        subtitleButton.setVisibility(View.GONE);
                    }
                } else {
                    subtitleButton.setVisibility(View.GONE);
                }
                if (videos != null) {
                    if (videos.size() < 1)
                        serverButton.setVisibility(View.GONE);
    
                }
    
            }
    
        }
    
        @Override
        protected void onStart() {
            super.onStart();
            PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
            wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "My Tag:");
    
            subtitleButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
    
                    //open subtitle dialog
                    openSubtitleDialog();
                }
            });
    
            serverButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    //open server dialog
                    openServerDialog(videos);
                }
            });
    
    
            //set title, description and poster in controller layout
            movieTitleTV.setText(model.getTitle());
            movieDescriptionTV.setText(model.getDescription());
            if (category.equalsIgnoreCase("tv")) {
                Picasso.get()
                        .load(model.getCardImageUrl())
                        .placeholder(R.drawable.poster_placeholder)
                        .centerCrop()
                        .resize(200, 120)
                        .error(R.drawable.poster_placeholder)
                        .into(posterImageViewForTV);
            }else {
                Picasso.get()
                        .load(model.getCardImageUrl())
                        .placeholder(R.drawable.poster_placeholder)
                        .centerCrop()
                        .resize(120, 200)
                        .error(R.drawable.poster_placeholder)
                        .into(posterImageView);
            }
        }
    
        @Override
        protected void onUserLeaveHint() {
            Log.e("RemoteKey", "DPAD_HOME");
            /** Use pressed home button **/
            //time to set media session active
            super.onUserLeaveHint();
        }
    
        boolean doubleBackToExitPressedOnce = false;
    
        @Override
        public boolean onKeyDown(int keyCode, KeyEvent event) {
    
            switch (keyCode) {
                case KeyEvent.KEYCODE_MOVE_HOME:
    
                    break;
                case KeyEvent.KEYCODE_DPAD_UP:
                    if (!exoPlayerView.isControllerVisible()) {
                        exoPlayerView.showController();
                    }
                    break;
                case KeyEvent.KEYCODE_DPAD_DOWN:
                    Log.e("RemoteKey", "DPAD_DOWN");
                    if (!exoPlayerView.isControllerVisible()) {
                        exoPlayerView.showController();
                    }
                    break;
                case KeyEvent.KEYCODE_DPAD_RIGHT:
                    Log.e("RemoteKey", "DPAD_RIGHT");
                    if (!exoPlayerView.isControllerVisible()) {
                        exoPlayerView.showController();
                    }
                    break;
                case KeyEvent.KEYCODE_DPAD_LEFT:
                    Log.e("RemoteKey", "DPAD_LEFT");
                    if (!exoPlayerView.isControllerVisible()) {
                        exoPlayerView.showController();
                    }
                    break;
                case KeyEvent.KEYCODE_DPAD_CENTER:
                    Log.e("RemoteKey", "DPAD_CENTER");
                    if (!exoPlayerView.isControllerVisible()) {
                        exoPlayerView.showController();
                    }
                    break;
                case KeyEvent.KEYCODE_BACK:
                    Log.e("RemoteKey", "DPAD_BACK");
                    if (exoPlayerView.isControllerVisible()) {
                        exoPlayerView.hideController();
                        finish();
                    }else{
                        exoPlayerView.showController();
                    }
    //                else {
    //                    if (doubleBackToExitPressedOnce) {
    //                        releasePlayer();
    //                        //mediaSessionHelper.stopMediaSession();
    //                        finish();
    //                    } else {
    //                        handleBackPress();
    //                    }
    //                }
    
                    break;
                case KeyEvent.KEYCODE_ESCAPE:
                    Log.e("RemoteKey", "DPAD_ESCAPE");
                   /* if (!exoPlayerView.isControllerVisible()){
                        exoPlayerView.showController();
                    }else {
                        releasePlayer();
                        finish();
                    }*/
                    break;
            }
            return false;
        }
    
    
        private void handleBackPress() {
            this.doubleBackToExitPressedOnce = true;
            //Toast.makeText(this, "Please click BACK again to exit.", Toast.LENGTH_SHORT).show();
            new ToastMsg(PlayerActivity.this).toastIconSuccess("Clique em VOLTAR novamente para sair.");
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    doubleBackToExitPressedOnce = false;
                }
            }, 2000);
    
        }
    
        private void openServerDialog(List<Video> videos) {
            if (videos != null) {
                List<Video> videoList = new ArrayList<>();
                videoList.clear();
    
                for (Video video : videos) {
                    if (!video.getFileType().equalsIgnoreCase("embed")) {
                        videoList.add(video);
                    }
                }
    
                AlertDialog.Builder builder = new AlertDialog.Builder(PlayerActivity.this);
                View view = LayoutInflater.from(PlayerActivity.this).inflate(R.layout.layout_server_tv, null);
                RecyclerView serverRv = view.findViewById(R.id.serverRv);
                ServerAdapter serverAdapter = new ServerAdapter(PlayerActivity.this, videoList, "movie");
                serverRv.setLayoutManager(new LinearLayoutManager(PlayerActivity.this));
                serverRv.setHasFixedSize(true);
                serverRv.setAdapter(serverAdapter);
    
                Button closeBt = view.findViewById(R.id.close_bt);
    
                builder.setView(view);
    
                final AlertDialog dialog = builder.create();
                dialog.show();
    
                closeBt.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog.dismiss();
                    }
                });
    
                final ServerAdapter.OriginalViewHolder[] viewHolder = {null};
                serverAdapter.setOnItemClickListener(new ServerAdapter.OnItemClickListener() {
    
                    @Override
                    public void onItemClick(View view, Video obj, int position, ServerAdapter.OriginalViewHolder holder) {
                        Intent playerIntent = new Intent(PlayerActivity.this, PlayerActivity.class);
                        PlaybackModel video = new PlaybackModel();
                        video.setId(model.getId());
                        video.setTitle(model.getTitle());
                        video.setDescription(model.getDescription());
                        video.setCategory("movie");
                        video.setVideo(obj);
                        video.setVideoList(model.getVideoList());
                        video.setVideoUrl(obj.getFileUrl());
                        video.setVideoType(obj.getFileType());
                        video.setBgImageUrl(model.getBgImageUrl());
                        video.setCardImageUrl(model.getCardImageUrl());
                        video.setIsPaid(model.getIsPaid());
    
                        playerIntent.putExtra(VideoPlaybackActivity.EXTRA_VIDEO, video);
    
                        startActivity(playerIntent);
                        dialog.dismiss();
                        finish();
                    }
                });
            } else {
                new ToastMsg(this).toastIconError(getString(R.string.no_other_server_found));
            }
        }
    
        private void openSubtitleDialog() {
            if (video != null) {
                if (!video.getSubtitle().isEmpty()) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(PlayerActivity.this);
                    View view = LayoutInflater.from(PlayerActivity.this).inflate(R.layout.layout_subtitle_dialog, null);
                    RecyclerView serverRv = view.findViewById(R.id.serverRv);
                    SubtitleListAdapter adapter = new SubtitleListAdapter(PlayerActivity.this, video.getSubtitle());
                    serverRv.setLayoutManager(new LinearLayoutManager(PlayerActivity.this));
                    serverRv.setHasFixedSize(true);
                    serverRv.setAdapter(adapter);
    
                    Button closeBt = view.findViewById(R.id.close_bt);
    
                    builder.setView(view);
                    final AlertDialog dialog = builder.create();
                    dialog.show();
    
                    closeBt.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            dialog.dismiss();
                        }
                    });
                    //click event
                    adapter.setListener(new SubtitleListAdapter.OnSubtitleItemClickListener() {
                        @Override
                        public void onSubtitleItemClick(View view, Subtitle subtitle, int position, SubtitleListAdapter.SubtitleViewHolder holder) {
                            setSelectedSubtitle(mediaSource, subtitle.getUrl());
                            dialog.dismiss();
                        }
                    });
    
                } else {
                    new ToastMsg(this).toastIconError(getResources().getString(R.string.no_subtitle_found));
                }
            } else {
                new ToastMsg(this).toastIconError(getResources().getString(R.string.no_subtitle_found));
            }
        }
    
        private void setSelectedSubtitle(com.google.android.exoplayer2.source.MediaSource mediaSource, String url) {
            MergingMediaSource mergedSource;
            if (url != null) {
                Uri subtitleUri = Uri.parse(url);
    
                Format subtitleFormat = Format.createTextSampleFormat(
                        null, // An identifier for the track. May be null.
                        MimeTypes.TEXT_VTT, // The mime type. Must be set correctly.
                        Format.NO_VALUE, // Selection flags for the track.
                        "en"); // The subtitle language. May be null.
    
                DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(PlayerActivity.this,
                        Util.getUserAgent(PlayerActivity.this, CLASS_NAME), new DefaultBandwidthMeter());
    
    
                com.google.android.exoplayer2.source.MediaSource subtitleSource = new SingleSampleMediaSource
                        .Factory(dataSourceFactory)
                        .createMediaSource(subtitleUri, subtitleFormat, C.TIME_UNSET);
    
    
                mergedSource = new MergingMediaSource(mediaSource, subtitleSource);
                player.prepare(mergedSource, false, false);
                player.setPlayWhenReady(true);
                //resumePlayer();
    
            } else {
                Toast.makeText(PlayerActivity.this, "não há legenda", Toast.LENGTH_SHORT).show();
            }
        }
    
        public void initVideoPlayer(String url, String type) {
            if (player != null) {
                player.release();
            }
    
            progressBar.setVisibility(VISIBLE);
            BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
            TrackSelection.Factory videoTrackSelectionFactory = new
                    AdaptiveTrackSelection.Factory(bandwidthMeter);
    
            TrackSelector trackSelector = new
                    DefaultTrackSelector(videoTrackSelectionFactory);
    
            player = ExoPlayerFactory.newSimpleInstance((Context) PlayerActivity.this, trackSelector);
            exoPlayerView.setPlayer(player);
            // below 2 lines will make screen size to fit
            exoPlayerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL);
            player.setVideoScalingMode(C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
            exoPlayerView.setControllerShowTimeoutMs(5000);
            player.setPlayWhenReady(true);
    
            Uri uri = Uri.parse(url);
    
            switch (type) {
                case "hls":
                    mediaSource = hlsMediaSource(uri, PlayerActivity.this);
                    break;
               /* case "youtube":
                    extractYoutubeUrl(url, PlayerActivity.this, 18);
                    break;
                case "youtube-live":
                    extractYoutubeUrl(url, PlayerActivity.this, 133);
                    break;*/
                case "rtmp":
                    mediaSource = rtmpMediaSource(uri);
                    break;
                default:
                    mediaSource = mediaSource(uri, PlayerActivity.this);
                    break;
            }
    
            if (!type.contains("youtube")) {
                player.prepare(mediaSource, true, false);
                exoPlayerView.setPlayer(player);
                player.setPlayWhenReady(true);
            }
    
            seekToStartPosition();
    
            player.addListener(new Player.DefaultEventListener() {
                @Override
                public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
                    if (playWhenReady && playbackState == Player.STATE_READY) {
                        isPlaying = true;
                        progressBar.setVisibility(View.GONE);
    
                        //create media session
                        // mediaSessionHelper = new MediaSessionHelper(player, PlayerActivity.this, model, isPlaying);
                        // mediaSessionHelper.updateMetadata();
                        //mediaSessionHelper.updatePlaybackState();
    
                    } else if (playbackState == Player.STATE_READY) {
                        isPlaying = false;
                        progressBar.setVisibility(View.GONE);
                        //add watch next card
                        long position = player.getCurrentPosition();
                        long duration = player.getDuration();
                        /*mediaSessionHelper.updateMetadata();
                        mediaSessionHelper.updatePlaybackState();*/
    
                    } else if (playbackState == Player.STATE_BUFFERING) {
                        isPlaying = false;
                        progressBar.setVisibility(VISIBLE);
                        player.setPlayWhenReady(true);
    
                    } else if (playbackState == Player.STATE_ENDED) {
                        //remove now playing card
                        //mediaSessionHelper.stopMediaSession();
                    } else {
                        // player paused in any state
                        isPlaying = false;
                        progressBar.setVisibility(View.GONE);
                    }
                }
            });
    
            exoPlayerView.setControllerVisibilityListener(new PlayerControlView.VisibilityListener() {
                @Override
                public void onVisibilityChange(int visibility) {
                    visible = visibility;
                }
            });
        }
    
        private void seekToStartPosition() {
            // Skip ahead if given a starting position.
            if (mStartingPosition > -1L) {
                if (player.getPlayWhenReady()) {
                    Log.d("VideoFragment", "Is prepped, seeking to " + mStartingPosition);
                    player.seekTo(mStartingPosition);
                }
            }
        }
    
    
        private com.google.android.exoplayer2.source.MediaSource mp3MediaSource(Uri uri) {
            DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getApplicationContext(), "Dalvik/2.1.0 (Linux; U; Android 7.1.2; ASUS_Z01QD Build/N2G48H)");
            ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
            Handler mainHandler = new Handler();
            return new ExtractorMediaSource(uri, dataSourceFactory, extractorsFactory, mainHandler, null);
        }
    
        private com.google.android.exoplayer2.source.MediaSource mediaSource(Uri uri, Context context) {
            return new ExtractorMediaSource.Factory(
                    new DefaultHttpDataSourceFactory("Dalvik/2.1.0 (Linux; U; Android 7.1.2; ASUS_Z01QD Build/N2G48H)")).
                    createMediaSource(uri);
        }
    
        private com.google.android.exoplayer2.source.MediaSource rtmpMediaSource(Uri uri) {
            com.google.android.exoplayer2.source.MediaSource videoSource = null;
    
            RtmpDataSourceFactory dataSourceFactory = new RtmpDataSourceFactory();
            videoSource = new ExtractorMediaSource.Factory(dataSourceFactory)
                    .createMediaSource(uri);
    
            return videoSource;
        }
    
       /* @SuppressLint("StaticFieldLeak")
        private void extractYoutubeUrl(String url, final Context context, final int tag) {
    
            new YouTubeExtractor(context) {
                @Override
                public void onExtractionComplete(SparseArray<YtFile> ytFiles, VideoMeta vMeta) {
                    if (ytFiles != null) {
                        int itag = tag;
                        String dashUrl = ytFiles.get(itag).getUrl();
    
                        try {
                            com.google.android.exoplayer2.source.MediaSource source = mediaSource(Uri.parse(dashUrl), context);
                            player.prepare(source, true, false);
                            //player.setPlayWhenReady(false);
                            exoPlayerView.setPlayer(player);
                            player.setPlayWhenReady(true);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
            }.extract(url, true, true);
        }*/
    
        private com.google.android.exoplayer2.source.MediaSource hlsMediaSource(Uri uri, Context context) {
    
            DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
            DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(context,
                    Util.getUserAgent(context, "Dalvik/2.1.0 (Linux; U; Android 7.1.2; ASUS_Z01QD Build/N2G48H)"), bandwidthMeter);
            com.google.android.exoplayer2.source.MediaSource videoSource = new HlsMediaSource.Factory(dataSourceFactory)
                    .createMediaSource(uri);
    
            return videoSource;
        }
    
        @Override
        public void onBackPressed() {
            if (visible == View.GONE) {
                exoPlayerView.showController();
            } else {
                releasePlayer();
                super.onBackPressed();
            }
    
        }
    
        @Override
        protected void onDestroy() {
            super.onDestroy();
            releasePlayer();
            if (wakeLock != null)
                wakeLock.release();
        }
    
        @Override
        protected void onPause() {
            super.onPause();
            releasePlayer();
        }
    
        @Override
        protected void onResume() {
            super.onResume();
            setVolumeControlStream(AudioManager.STREAM_MUSIC);
            wakeLock.acquire(10 * 60 * 1000L /*10 minutes*/);
        }
    
        private void releasePlayer() {
            if (player != null) {
                player.setPlayWhenReady(false);
                player.stop();
                player.release();
                player = null;
                exoPlayerView.setPlayer(null);
            }
        }
    
        @Override
        public void onInitializationComplete() {
    
        }
    
        @Override
        public void onInitializationFailed(UnityAds.UnityAdsInitializationError unityAdsInitializationError, String s) {
    
        }
    }
    
    opened by pllinformatica 0
  • Is it ok to use `runBlocking{}` on ExoPlayer's playback thread?

    Is it ok to use `runBlocking{}` on ExoPlayer's playback thread?

    Didn't get any answers to my stackoverflow question :disappointed: so here goes again!

    I need to make a network call just before playback (similar in part to this issue). In this case, the network result is also used to to build AdsConfiguration and DrmConfiguration, which are provided to the MediaItem.Builder.

    The following code works fine, but I cannot find documentation that confirms it's ok!

    override fun createMediaSource(mediaItem: MediaItem): MediaSource {
        val builder = mediaItem.buildUpon()
    
    // Is it ok to use `runBlocking` here?
        val remoteData = runBlocking {
             fetchPlayableMedia()
        }
    
        remoteData?.let {
            builder.setUri(it.mediaUri)
                .setAdsConfiguration(it.toAdsConfiguration())
                .setDrmConfiguration(it.toDrmConfiguration())
        }
    
        return mediaSourceDelegate.createMediaSource(builder.build())
    }
    

    MediaSource doc says

    All methods are called on the player's internal playback thread
    

    which is different from the background thread.

    I tried using a ResolvingDataSource, where documentation for resolveDataSpec() clearly mentions

    This method is allowed to block until the DataSpec has been resolved.
    

    But resolveDataSpec() is called only after createMediaSource(mediaItem), so it seems too late to set Ads/DRM configuration.

    The DataSourceFactory does call createDataSource(), but I'm not sure if httpDataSource.setRequestProperty() can be used to configure Ads/DRM.

    To put it differently: how can one do a network call on ExoPlayer's background thread, just before playback, and use the data to set Ads/DRM configuration?

    question needs triage 
    opened by mudar 3
  • DefaultHttpDataSource disconnects after 20sec on chromebook

    DefaultHttpDataSource disconnects after 20sec on chromebook

    I have 2 HP Chromebooks X2-v1 & X2-v2, both disconnect after approx 15 seconds from my app's HTTP server. If I connect VLC or my app exoplayer on an android only tablet it works OK.

    Has anyone experienced something similar?

    Thanks

    question needs triage 
    opened by rcvangemert 0
Releases(r2.18.2)
  • r2.18.2(Nov 23, 2022)

    • Core library:
      • Add ExoPlayer.isTunnelingEnabled to check if tunneling is enabled for the currently selected tracks (https://github.com/google/ExoPlayer/issues/2518).
      • Add WrappingMediaSource to simplify wrapping a single MediaSource (https://github.com/google/ExoPlayer/issues/7279).
      • Discard back buffer before playback gets stuck due to insufficient available memory.
      • Close the Tracing "doSomeWork" block when offload is enabled.
      • Fix session tracking problem with fast seeks in PlaybackStatsListener (https://github.com/androidx/media/issues/180).
      • Send missing onMediaItemTransition callback when calling seekToNext or seekToPrevious in a single-item playlist (https://github.com/google/ExoPlayer/issues/10667).
      • Add Player.getSurfaceSize that returns the size of the surface on which the video is rendered.
      • Fix bug where removing listeners during the player release can cause an IllegalStateException (https://github.com/google/ExoPlayer/issues/10758).
    • Build:
      • Enforce minimum compileSdkVersion to avoid compilation errors (https://github.com/google/ExoPlayer/issues/10684).
      • Avoid publishing block when included in another gradle build.
    • Track selection:
      • Prefer other tracks to Dolby Vision if display does not support it. (https://github.com/google/ExoPlayer/issues/8944).
    • Downloads:
      • Fix potential infinite loop in ProgressiveDownloader caused by simultaneous download and playback with the same PriorityTaskManager (https://github.com/google/ExoPlayer/pull/10570).
      • Make download notification appear immediately (https://github.com/androidx/media/pull/183).
      • Limit parallel download removals to 1 to avoid excessive thread creation (https://github.com/google/ExoPlayer/issues/10458).
    • Video:
      • Try alternative decoder for Dolby Vision if display does not support it. (https://github.com/google/ExoPlayer/issues/9794).
    • Audio:
      • Use SingleThreadExecutor for releasing AudioTrack instances to avoid OutOfMemory errors when releasing multiple players at the same time (https://github.com/google/ExoPlayer/issues/10057).
      • Adds AudioOffloadListener.onExperimentalOffloadedPlayback for the AudioTrack offload state. (https://github.com/androidx/media/issues/134).
      • Make AudioTrackBufferSizeProvider a public interface.
      • Add ExoPlayer.setPreferredAudioDevice to set the preferred audio output device (https://github.com/androidx/media/issues/135).
      • Rename com.google.android.exoplayer2.audio.AudioProcessor to com.google.android.exoplayer2.audio.AudioProcessor.
      • Map 8-channel and 12-channel audio to the 7.1 and 7.1.4 channel masks respectively on all Android versions (https://github.com/google/ExoPlayer/issues/10701).
    • Metadata:
      • MetadataRenderer can now be configured to render metadata as soon as they are available. Create an instance with MetadataRenderer(MetadataOutput, Looper, MetadataDecoderFactory, boolean) to specify whether the renderer will output metadata early or in sync with the player position.
    • DRM:
      • Work around a bug in the Android 13 ClearKey implementation that returns a non-empty but invalid license URL.
      • Fix setMediaDrmSession failed: session not opened error when switching between DRM schemes in a playlist (e.g. Widevine to ClearKey).
    • Text:
      • CEA-608: Ensure service switch commands on field 2 are handled correctly (https://github.com/google/ExoPlayer/issues/10666).
    • DASH:
      • Parse EventStream.presentationTimeOffset from manifests (https://github.com/google/ExoPlayer/issues/10460).
    • UI:
      • Use current overrides of the player as preset in TrackSelectionDialogBuilder (https://github.com/google/ExoPlayer/issues/10429).
    • RTSP:
      • Add H263 fragmented packet handling (https://github.com/androidx/media/pull/119).
      • Add support for MP4A-LATM (https://github.com/androidx/media/pull/162).
    • IMA:
      • Add timeout for loading ad information to handle cases where the IMA SDK gets stuck loading an ad (https://github.com/google/ExoPlayer/issues/10510).
      • Prevent skipping mid-roll ads when seeking to the end of the content (https://github.com/google/ExoPlayer/issues/10685).
      • Correctly calculate window duration for live streams with server-side inserted ads, for example IMA DAI (https://github.com/google/ExoPlayer/issues/10764).
    • FFmpeg extension:
      • Add newly required flags to link FFmpeg libraries with NDK 23.1.7779620 and above (https://github.com/google/ExoPlayer/issues/9933).
    • AV1 extension:
      • Update CMake version to avoid incompatibilities with the latest Android Studio releases (https://github.com/google/ExoPlayer/issues/9933).
    • Cast extension:
      • Implement getDeviceInfo() to be able to identify CastPlayer when controlling playback with a MediaController (https://github.com/androidx/media/issues/142).
    • Transformer:
      • Add muxer watchdog timer to detect when generating an output sample is too slow.
    • Remove deprecated symbols:
      • Remove Transformer.Builder.setOutputMimeType(String). This feature has been removed. The MIME type will always be MP4 when the default muxer is used.
    Source code(tar.gz)
    Source code(zip)
  • r2.18.1(Jul 22, 2022)

    This release corresponds to the AndroidX media3 1.0.0-beta02 release.

    • Core library:
      • Ensure that changing the ShuffleOrder with ExoPlayer.setShuffleOrder results in a call to Player.Listener#onTimelineChanged with reason=Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED (#9889).
      • For progressive media, only include selected tracks in buffered position (#10361).
      • Allow custom logger for all ExoPlayer log output (#9752).
      • Fix implementation of setDataSourceFactory in DefaultMediaSourceFactory, which was non-functional in some cases (#116).
    • Extractors:
      • Fix parsing of H265 short term reference picture sets (#10316).
      • Fix parsing of bitrates from esds boxes (#10381).
    • DASH:
      • Parse ClearKey license URL from manifests (#10246).
    • UI:
      • Ensure TalkBack announces the currently active speed option in the playback controls menu (#10298).
    • RTSP:
      • Add VP8 fragmented packet handling (#110).
    • Leanback extension:
      • Listen to playWhenReady changes in LeanbackAdapter (10420).
    • Cast:
      • Use the MediaItem that has been passed to the playlist methods as Window.mediaItem in CastTimeline (#25, #8212).
      • Support Player.getMetadata() and Listener.onMediaMetadataChanged() with CastPlayer (#25).
    Source code(tar.gz)
    Source code(zip)
  • r2.18.0(Jun 17, 2022)

    This release corresponds to the AndroidX media3 1.0.0-beta01 release.

    • Core library:
      • Enable support for Android platform diagnostics via MediaMetricsManager. ExoPlayer will forward playback events and performance data to the platform, which helps to provide system performance and debugging information on the device. This data may also be collected by Google if sharing usage and diagnostics data is enabled by the user of the device. Apps can opt-out of contributing to platform diagnostics for ExoPlayer with ExoPlayer.Builder.setUsePlatformDiagnostics(false).
      • Fix bug that tracks are reset too often when using MergingMediaSource, for example when side-loading subtitles and changing the selected subtitle mid-playback (#10248).
      • Stop detecting 5G-NSA network type on API 29 and 30. These playbacks will assume a 4G network.
      • Disallow passing null to MediaSource.Factory.setDrmSessionManagerProvider and MediaSource.Factory.setLoadErrorHandlingPolicy. Instances of DefaultDrmSessionManagerProvider and DefaultLoadErrorHandlingPolicy can be passed explicitly if required.
      • Add MediaItem.RequestMetadata to represent metadata needed to play media when the exact LocalConfiguration is not known. Also remove MediaMetadata.mediaUrl as this is now included in RequestMetadata.
      • Add Player.Command.COMMAND_SET_MEDIA_ITEM to enable players to allow setting a single item.
    • Track selection:
      • Flatten TrackSelectionOverrides class into TrackSelectionParameters, and promote TrackSelectionOverride to a top level class.
      • Rename TracksInfo to Tracks and TracksInfo.TrackGroupInfo to Tracks.Group. Player.getCurrentTracksInfo and Player.Listener.onTracksInfoChanged have also been renamed to Player.getCurrentTracks and Player.Listener.onTracksChanged. This includes 'un-deprecating' the Player.Listener.onTracksChanged method name, but with different parameter types.
      • Change DefaultTrackSelector.buildUponParameters and DefaultTrackSelector.Parameters.buildUpon to return DefaultTrackSelector.Parameters.Builder instead of the deprecated DefaultTrackSelector.ParametersBuilder.
      • Add DefaultTrackSelector.Parameters.constrainAudioChannelCountToDeviceCapabilities which is enabled by default. When enabled, the DefaultTrackSelector will prefer audio tracks whose channel count does not exceed the device output capabilities. On handheld devices, the DefaultTrackSelector will prefer stereo/mono over multichannel audio formats, unless the multichannel format can be Spatialized (Android 12L+) or is a Dolby surround sound format. In addition, on devices that support audio spatialization, the DefaultTrackSelector will monitor for changes in the Spatializer properties and trigger a new track selection upon these. Devices with a television UI mode are excluded from these constraints and the format with the highest channel count will be preferred. To enable this feature, the DefaultTrackSelector instance must be constructed with a Context.
    • Video:
      • Rename DummySurface to PlaceholderSurface.
      • Add AV1 support to the MediaCodecVideoRenderer.getCodecMaxInputSize.
    • Audio:
      • Use LG AC3 audio decoder advertising non-standard MIME type.
      • Change the return type of AudioAttributes.getAudioAttributesV21() from android.media.AudioAttributes to a new AudioAttributesV21 wrapper class, to prevent slow ART verification on API < 21.
      • Query the platform (API 29+) or assume the audio encoding channel count for audio passthrough when the format audio channel count is unset, which occurs with HLS chunkless preparation (10204).
      • Configure AudioTrack with channel mask AudioFormat.CHANNEL_OUT_7POINT1POINT4 if the decoder outputs 12 channel PCM audio (#10322.
    • DRM
      • Ensure the DRM session is always correctly updated when seeking immediately after a format change (10274).
    • Text:
      • Change Player.getCurrentCues() to return CueGroup instead of List<Cue>.
      • SSA: Support OutlineColour style setting when BorderStyle == 3 (i.e. OutlineColour sets the background of the cue) (#8435).
      • CEA-708: Parse data into multiple service blocks and ignore blocks not associated with the currently selected service number.
      • Remove RawCcExtractor, which was only used to handle a Google-internal subtitle format.
    • Extractors:
      • Matroska: Parse DiscardPadding for Opus tracks.
      • MP4: Parse bitrates from esds boxes.
      • Ogg: Allow duplicate Opus ID and comment headers (#10038).
    • UI:
      • Fix delivery of events to OnClickListeners set on StyledPlayerView and PlayerView, in the case that useController=false (#9605). Also fix delivery of events to OnLongClickListener for all view configurations.
      • Fix incorrectly treating a sequence of touch events that exit the bounds of StyledPlayerView and PlayerView before ACTION_UP as a click (#9861).
      • Fix PlayerView accessibility issue where tapping might toggle playback rather than hiding the controls (#8627).
      • Rewrite TrackSelectionView and TrackSelectionDialogBuilder to work with the Player interface rather than ExoPlayer. This allows the views to be used with other Player implementations, and removes the dependency from the UI module to the ExoPlayer module. This is a breaking change.
      • Don't show forced text tracks in the PlayerView track selector, and keep a suitable forced text track selected if "None" is selected (#9432).
    • DASH:
      • Parse channel count from DTS AudioChannelConfiguration elements. This re-enables audio passthrough for DTS streams (#10159).
      • Disallow passing null to DashMediaSource.Factory.setCompositeSequenceableLoaderFactory. Instances of DefaultCompositeSequenceableLoaderFactory can be passed explicitly if required.
    • HLS:
      • Fallback to chunkful preparation if the playlist CODECS attribute does not contain the audio codec (#10065).
      • Disallow passing null to HlsMediaSource.Factory.setCompositeSequenceableLoaderFactory, HlsMediaSource.Factory.setPlaylistParserFactory, and HlsMediaSource.Factory.setPlaylistTrackerFactory. Instances of DefaultCompositeSequenceableLoaderFactory, DefaultHlsPlaylistParserFactory, or a reference to DefaultHlsPlaylistTracker.FACTORY can be passed explicitly if required.
    • Smooth Streaming:
      • Disallow passing null to SsMediaSource.Factory.setCompositeSequenceableLoaderFactory. Instances of DefaultCompositeSequenceableLoaderFactory can be passed explicitly if required.
    • RTSP:
      • Add RTP reader for MPEG4 (#35).
      • Add RTP reader for HEVC (#36).
      • Add RTP reader for AMR. Currently only mono-channel, non-interleaved AMR streams are supported. Compound AMR RTP payload is not supported. (#46)
      • Add RTP reader for VP8 (#47).
      • Add RTP reader for WAV (#56).
      • Fix RTSP basic authorization header. (#9544).
      • Stop checking mandatory SDP fields as ExoPlayer doesn't need them (#10049).
      • Throw checked exception when parsing RTSP timing (#10165).
      • Add RTP reader for VP9 (#47).
      • Add RTP reader for OPUS (#53).
    • Data sources:
      • Rename DummyDataSource to PlaceholderDataSource.
      • Workaround OkHttp interrupt handling.
    • Ad playback / IMA:
      • Decrease ad polling rate from every 100ms to every 200ms, to line up with Media Rating Council (MRC) recommendations.
    • FFmpeg extension:
      • Update CMake version to 3.21.0+ to avoid a CMake bug causing AndroidStudio's gradle sync to fail (#9933).
    • Remove deprecated symbols:
      • Remove Player.Listener.onTracksChanged(TrackGroupArray, TrackSelectionArray). Use Player.Listener.onTracksChanged(Tracks) instead.
      • Remove Player.getCurrentTrackGroups and Player.getCurrentTrackSelections. Use Player.getCurrentTracks instead. You can also continue to use ExoPlayer.getCurrentTrackGroups and ExoPlayer.getCurrentTrackSelections, although these methods remain deprecated.
      • Remove DownloadHelper DEFAULT_TRACK_SELECTOR_PARAMETERS_WITHOUT_VIEWPORT and DEFAULT_TRACK_SELECTOR_PARAMETERS constants. Use getDefaultTrackSelectorParameters(Context) instead when possible, and DEFAULT_TRACK_SELECTOR_PARAMETERS_WITHOUT_CONTEXT otherwise.
      • Remove constructor DefaultTrackSelector(ExoTrackSelection.Factory). Use DefaultTrackSelector(Context, ExoTrackSelection.Factory) instead.
      • Remove Transformer.Builder.setContext. The Context should be passed to the Transformer.Builder constructor instead.
    Source code(tar.gz)
    Source code(zip)
  • r2.17.1(Mar 10, 2022)

    This release corresponds to the AndroidX media3 1.0.0-alpha03 release.

    • Audio:
      • Fix error checking audio capabilities for Dolby Atmos (E-AC3-JOC) in HLS.
    • Extractors:
      • FMP4: Fix issue where emsg sample metadata could be output in the wrong order for streams containing both v0 and v1 emsg atoms (#9996).
    • Text:
      • Fix the interaction of SingleSampleMediaSource.Factory.setTrackId and MediaItem.SubtitleConfiguration.Builder.setId to prioritise the SubtitleConfiguration field and fall back to the Factory value if it's not set (#10016).
    • Ad playback:
      • Fix audio underruns between ad periods in live HLS SSAI streams.
    Source code(tar.gz)
    Source code(zip)
  • r2.17.0(Feb 24, 2022)

    • Core library:
      • Sleep and retry when creating a MediaCodec instance fails. This works around an issue that occurs on some devices when switching a surface from a secure codec to another codec (#8696).
      • Add MediaCodecAdapter.getMetrics() to allow users obtain metrics data from MediaCodec (#9766).
      • Fix Maven dependency resolution (#8353).
      • Disable automatic speed adjustment for live streams that neither have low-latency features nor a user request setting the speed (#9329).
      • Rename DecoderCounters#inputBufferCount to queuedInputBufferCount.
      • Make SimpleExoPlayer.renderers private. Renderers can be accessed via ExoPlayer.getRenderer.
      • Updated some AnalyticsListener.EventFlags constant values to match values in Player.EventFlags.
      • Split AnalyticsCollector into an interface and default implementation to allow it to be stripped by R8 if an app doesn't need it.
    • Track selection:
      • Support preferred video role flags in track selection (#9402).
      • Update video track selection logic to take preferred MIME types and role flags into account when selecting multiple video tracks for adaptation (#9519).
      • Update video and audio track selection logic to only choose formats for adaptive selections that have the same level of decoder and hardware support (#9565).
      • Update video track selection logic to prefer more efficient codecs if multiple codecs are supported by primary, hardware-accelerated decoders (#4835).
      • Prefer audio content preferences (for example, the "default" audio track or a track matching the system locale language) over technical track selection constraints (for example, preferred MIME type, or maximum channel count).
      • Prohibit duplicate TrackGroups in a TrackGroupArray. TrackGroups can always be made distinguishable by setting an id in the TrackGroup constructor. This fixes a crash when resuming playback after backgrounding the app with an active track override (#9718).
      • Amend logic in AdaptiveTrackSelection to allow a quality increase under sufficient network bandwidth even if playback is very close to the live edge (#9784).
    • Video:
      • Fix decoder fallback logic for Dolby Vision to use a compatible H264/H265 decoder if needed.
    • Audio:
      • Fix decoder fallback logic for Dolby Atmos (E-AC3-JOC) to use a compatible E-AC3 decoder if needed.
      • Change AudioCapabilities APIs to require passing explicitly AudioCapabilities.DEFAULT_AUDIO_CAPABILITIES instead of null.
      • Allow customization of the AudioTrack buffer size calculation by injecting an AudioTrackBufferSizeProvider to DefaultAudioSink (#8891).
      • Retry AudioTrack creation if the requested buffer size was > 1MB (#9712).
    • Extractors:
      • Fix incorrect parsing of H.265 SPS NAL units (#9719).
      • Parse Vorbis Comments (including METADATA_BLOCK_PICTURE) in Ogg Opus and Ogg Vorbis files.
    • Text:
      • Add a MediaItem.SubtitleConfiguration.id field which is propagated to the Format.id field of the subtitle track created from the configuration (#9673).
      • Add basic support for WebVTT subtitles in Matroska containers (#9886).
      • Prevent Cea708Decoder from reading more than the declared size of a service block.
    • DRM:
      • Remove playbackLooper from DrmSessionManager.(pre)acquireSession. When a DrmSessionManager is used by an app in a custom MediaSource, the playbackLooper needs to be passed to DrmSessionManager.setPlayer instead.
    • Ad playback / IMA:
      • Add support for IMA Dynamic Ad Insertion (DAI) (#8213).
      • Add a method to AdPlaybackState to allow resetting an ad group so that it can be played again (#9615).
      • Enforce playback speed of 1.0 during ad playback (#9018).
      • Fix issue where an ad group that failed to load caused an immediate playback reset (#9929).
    • UI:
      • Fix the color of the numbers in StyledPlayerView rewind and fastforward buttons when using certain themes (#9765).
      • Correctly translate playback speed strings (#9811).
    • DASH:
      • Support the forced-subtitle track role (#9727).
      • Stop interpreting the main track role as C.SELECTION_FLAG_DEFAULT.
      • Fix base URL exclusion logic for manifests that do not declare the DVB namespace (#9856).
      • Support relative MPD.Location URLs (#9939).
    • HLS:
      • Use chunkless preparation by default to improve start up time. If your renditions contain muxed closed-caption tracks that are not declared in the master playlist, you should add them to the master playlist to be available for playback, or turn off chunkless preparation with HlsMediaSource.Factory.setAllowChunklessPreparation(false).
      • Support key-frame accurate seeking in HLS (#2882).
      • Correctly populate Format.label for audio only HLS streams (#9608).
    • RTSP:
      • Provide a client API to override the SocketFactory used for any server connection (#9606).
      • Prefer DIGEST authentication method over BASIC if both are present (#9800).
      • Handle when RTSP track timing is not available (#9775).
      • Ignore invalid RTP-Info header values (#9619).
    • Transformer:
      • Increase required min API version to 21.
      • TransformationException is now used to describe errors that occur during a transformation.
      • Add TransformationRequest for specifying the transformation options.
      • Allow multiple listeners to be registered.
      • Fix Transformer being stuck when the codec output is partially read.
      • Fix potential NPE in Transformer.getProgress when releasing the muxer throws.
      • Add a demo app for applying transformations.
      • The transformer module is no longer included by depending on com.google.android.exoplayer:exoplayer. To continue using transformer, add an additional dependency on com.google.android.exoplayer:exoplayer-transformer.
    • MediaSession extension:
      • By default, MediaSessionConnector now clears the playlist on stop. Apps that want the playlist to be retained can call setClearMediaItemsOnStop(false) on the connector.
    • Cast extension:
      • Fix bug that prevented CastPlayer from calling onIsPlayingChanged correctly (#9792).
      • Support audio metadata including artwork with DefaultMediaItemConverter (#9663).
    • FFmpeg extension:
      • Make build_ffmpeg.sh depend on LLVM's bin utils instead of GNU's (#9933).
    • Android 12 compatibility:
      • Upgrade the Cast extension to depend on com.google.android.gms:play-services-cast-framework:20.1.0. Earlier versions of play-services-cast-framework are not compatible with apps targeting Android 12, and will crash with an IllegalArgumentException when creating PendingIntents (#9528).
    • Remove deprecated symbols:
      • Remove Player.EventListener. Use Player.Listener instead.
      • Remove MediaSourceFactory#setDrmSessionManager, MediaSourceFactory#setDrmHttpDataSourceFactory, and MediaSourceFactory#setDrmUserAgent. Use MediaSourceFactory#setDrmSessionManagerProvider instead.
      • Remove MediaSourceFactory#setStreamKeys. Use MediaItem.Builder#setStreamKeys instead.
      • Remove MediaSourceFactory#createMediaSource(Uri). Use MediaSourceFactory#createMediaSource(MediaItem) instead.
      • Remove setTag from DashMediaSource, HlsMediaSource and SsMediaSource. Use MediaItem.Builder#setTag instead.
      • Remove DashMediaSource#setLivePresentationDelayMs(long, boolean). Use MediaItem.Builder#setLiveConfiguration and MediaItem.LiveConfiguration.Builder#setTargetOffsetMs to override the manifest, or DashMediaSource#setFallbackTargetLiveOffsetMs to provide a fallback value.
      • Remove (Simple)ExoPlayer.setThrowsWhenUsingWrongThread. Opting out of the thread enforcement is no longer possible.
      • Remove ActionFile and ActionFileUpgradeUtil. Use ExoPlayer 2.16.1 or before to use ActionFileUpgradeUtil to merge legacy action files into DefaultDownloadIndex.
      • Remove ProgressiveMediaSource#setExtractorsFactory. Use ProgressiveMediaSource.Factory(DataSource.Factory, ExtractorsFactory) constructor instead.
      • Remove ProgressiveMediaSource.Factory#setTag and, ProgressiveMediaSource.Factory#setCustomCacheKey. Use MediaItem.Builder#setTag and MediaItem.Builder#setCustomCacheKey instead.
      • Remove DefaultRenderersFactory(Context, @ExtensionRendererMode int) and DefaultRenderersFactory(Context, @ExtensionRendererMode int, long) constructors. Use the DefaultRenderersFactory(Context) constructor, DefaultRenderersFactory#setExtensionRendererMode, and DefaultRenderersFactory#setAllowedVideoJoiningTimeMs instead.
      • Remove all public CronetDataSource constructors. Use CronetDataSource.Factory instead.
    • Change the following IntDefs to @Target(TYPE_USE) only. This may break the compilation of usages in Kotlin, which can be fixed by moving the annotation to annotate the type (Int).
      • @AacAudioObjectType
      • @Ac3Util.SyncFrameInfo.StreamType
      • @AdLoadException.Type
      • @AdtsExtractor.Flags
      • @AmrExtractor.Flags
      • @AspectRatioFrameLayout.ResizeMode
      • @AudioFocusManager.PlayerCommand
      • @AudioSink.SinkFormatSupport
      • @BinarySearchSeeker.TimestampSearchResult.Type
      • @BufferReplacementMode
      • @C.BufferFlags
      • @C.ColorRange
      • @C.ColorSpace
      • @C.ColorTransfer
      • @C.CryptoMode
      • @C.Encoding
      • @C.PcmEncoding
      • @C.Projection
      • @C.SelectionReason
      • @C.StereoMode
      • @C.VideoOutputMode
      • @CacheDataSource.Flags
      • @CaptionStyleCompat.EdgeType
      • @DataSpec.Flags
      • @DataSpec.HttpMethods
      • @DecoderDiscardReasons
      • @DecoderReuseResult
      • @DefaultAudioSink.OutputMode
      • @DefaultDrmSessionManager.Mode
      • @DefaultTrackSelector.SelectionEligibility
      • @DefaultTsPayloadReaderFactory.Flags
      • @EGLSurfaceTexture.SecureMode
      • @EbmlProcessor.ElementType
      • @ExoMediaDrm.KeyRequest.RequestType
      • @ExtensionRendererMode
      • @Extractor.ReadResult
      • @FileTypes.Type
      • @FlacExtractor.Flags (in com.google.android.exoplayer2.ext.flac package)
      • @FlacExtractor.Flags (in com.google.android.exoplayer2.extractor.flac package)
      • @FragmentedMp4Extractor.Flags
      • @HlsMediaPlaylist.PlaylistType
      • @HttpDataSourceException.Type
      • @IllegalClippingException.Reason
      • @IllegalMergeException.Reason
      • @LoadErrorHandlingPolicy.FallbackType
      • @MatroskaExtractor.Flags
      • @Mp3Extractor.Flags
      • @Mp4Extractor.Flags
      • @NotificationUtil.Importance
      • @PlaybackException.FieldNumber
      • @PlayerNotificationManager.Priority
      • @PlayerNotificationManager.Visibility
      • @PlayerView.ShowBuffering
      • @Renderer.State
      • @RendererCapabilities.AdaptiveSupport
      • @RendererCapabilities.Capabilities
      • @RendererCapabilities.DecoderSupport
      • @RendererCapabilities.FormatSupport
      • @RendererCapabilities.HardwareAccelerationSupport
      • @RendererCapabilities.TunnelingSupport
      • @SampleStream.ReadDataResult
      • @SampleStream.ReadFlags
      • @StyledPlayerView.ShowBuffering
      • @SubtitleView.ViewType
      • @TextAnnotation.Position
      • @TextEmphasisSpan.MarkFill
      • @TextEmphasisSpan.MarkShape
      • @Track.Transformation
      • @TrackOutput.SampleDataPart
      • @Transformer.ProgressState
      • @TsExtractor.Mode
      • @TsPayloadReader.Flags
      • @WebvttCssStyle.FontSizeUnit
    Source code(tar.gz)
    Source code(zip)
  • r2.16.1(Nov 19, 2021)

    • Core Library:
      • Fix track selection issue where overriding one track group did not disable other track groups of the same type (#9675).
      • Fix track selection issue where a mixture of non-empty and empty track overrides is not applied correctly (#9649).
      • Add protected method DefaultRenderersFactory.getCodecAdapterFactory() so that subclasses of DefaultRenderersFactory that override buildVideoRenderers() or buildAudioRenderers() can access the codec adapter factory and pass it to MediaCodecRenderer instances they create.
      • Propagate ICY header fields name and genre to MediaMetadata.station and MediaMetadata.genre respectively so that they reach the app via Player.Listener.onMediaMetadataChanged() (#9677).
      • Remove null keys from DefaultHttpDataSource#getResponseHeaders.
    • Extractors:
      • WAV: Add support for RF64 streams (#9543).
    • DASH:
      • Add parsed essential and supplemental properties to the Representation (#9579).
    • HLS:
      • Correctly populate Format.label for audio only HLS streams (#9608).
    Source code(tar.gz)
    Source code(zip)
  • r2.16.0(Nov 4, 2021)

    • Core Library:
      • Deprecate SimpleExoPlayer. All functionality has been moved to ExoPlayer instead. ExoPlayer.Builder can be used instead of SimpleExoPlayer.Builder.
      • Add track selection methods to the Player interface, for example, Player.getCurrentTracksInfo and Player.setTrackSelectionParameters. These methods can be used instead of directly accessing the track selector.
      • Enable MediaCodec asynchronous queueing by default on devices with API level >= 31. Add methods in DefaultMediaCodecRendererFactory and DefaultRenderersFactory to force enable or force disable asynchronous queueing (6348).
      • Remove final dependency on jcenter().
      • Fix mediaMetadata being reset when media is repeated (#9458).
      • Adjust ExoPlayer MediaMetadata update priority, such that values input through the MediaItem.MediaMetadata are used above media derived values.
      • Move com.google.android.exoplayer2.device.DeviceInfo to com.google.android.exoplayer2.DeviceInfo.
      • Move com.google.android.exoplayer2.drm.DecryptionException to com.google.android.exoplayer2.decoder.CryptoException.
      • Move com.google.android.exoplayer2.upstream.cache.CachedRegionTracker to com.google.android.exoplayer2.upstream.CachedRegionTracker.
      • Move Player.addListener(EventListener) and Player.removeListener(EventListener) out of Player into subclasses.
    • Android 12 compatibility:
      • Keep DownloadService started and in the foreground whilst waiting for requirements to be met on Android 12. This is necessary due to new foreground service launch restrictions. DownloadService.getScheduler will not be called on Android 12 devices.
      • Disable platform transcoding when playing content URIs on Android 12.
      • Add ExoPlayer.setVideoChangeFrameRateStrategy to allow disabling of calls from the player to Surface.setFrameRate. This is useful for applications wanting to call Surface.setFrameRate directly from application code with Android 12's Surface.CHANGE_FRAME_RATE_ALWAYS.
      • Upgrade the WorkManager extension to depend on androidx.work:work-runtime:2.7.0. Earlier versions of work-runtime are not compatible with apps targeting Android 12, and will crash with an IllegalArgumentException when creating PendingIntents (#9181).
    • Video:
      • Fix bug in MediaCodecVideoRenderer that resulted in re-using a released Surface when playing without an app-provided Surface (#9476).
    • DRM:
      • Log an error (instead of throwing IllegalStateException) when calling DefaultDrmSession#release() on a fully released session (#9392).
    • UI:
      • SubtitleView no longer implements TextOutput. SubtitleView implements Player.Listener, so can be registered to a player with Player.addListener.
      • Fix initial timestamp display in PlayerControlView (#9524).
      • Fix capitalization of languages in the track selector (#9452).
    • Extractors:
      • MP4: Correctly handle HEVC tracks with pixel aspect ratios other than 1.
      • MP4: Add support for Dolby TrueHD (only for unfragmented streams) (#9496).
      • MP4: Avoid throwing ArrayIndexOutOfBoundsException when parsing invalid colr boxes produced by some device cameras (#9332).
      • MP4: Parse HDR static metadata from the clli and mdcv boxes.
      • TS: Correctly handle HEVC tracks with pixel aspect ratios other than 1.
      • TS: Map stream type 0x80 to H262 (#9472).
    • Downloads and caching:
      • Modify DownloadService behavior when DownloadService.getScheduler returns null, or returns a Scheduler that does not support the requirements for downloads to continue. In both cases, DownloadService will now remain started and in the foreground whilst waiting for requirements to be met.
      • Modify DownloadService behavior when running on Android 12 and above. See the "Android 12 compatibility" section above.
    • RTSP:
      • Support RFC4566 SDP attribute field grammar (#9430).
    • DASH:
      • Populate Format.sampleMimeType, width and height for image AdaptationSet elements (#9500).
    • HLS:
      • Fix rounding error in HLS playlists (#9575).
      • Fix NoSuchElementException thrown when an HLS manifest declares #EXT-X-RENDITION-REPORT at the beginning of the playlist (#9592).
    • RTMP extension:
      • Upgrade to io.antmedia:rtmp_client, which does not rely on jcenter() (#9591).
    • MediaSession extension:
      • Rename MediaSessionConnector.QueueNavigator#onCurrentWindowIndexChanged to onCurrentMediaItemIndexChanged.
    • Transformer:
      • Avoid sending a duplicate timestamp to the encoder with the end of stream buffer.
    • Remove deprecated symbols:
      • Remove Renderer.VIDEO_SCALING_MODE_* constants. Use identically named constants in C instead.
      • Remove C.MSG_* constants. Use identically named constants in Renderer instead, except for C.MSG_SET_SURFACE, which is replaced with Renderer.MSG_SET_VIDEO_OUTPUT.
      • Remove DeviceListener. Use Player.Listener instead.
      • Remove CacheDataSourceFactory. Use CacheDataSource.Factory instead.
      • Remove CacheDataSinkFactory. Use CacheDataSink.Factory instead.
      • Remove FileDataSourceFactory. Use FileDataSource.Factory instead.
      • Remove SimpleExoPlayer.addMetadataOutput and removeMetadataOutput. Use Player.addListener and Player.Listener instead.
      • Remove SimpleExoPlayer.addAudioListener, removeAudioListener and AudioListener. Use Player.addListener and Player.Listener instead.
      • Remove SimpleExoPlayer.addVideoListener, removeVideoListener and VideoListener. Use Player.addListener and Player.Listener instead.
      • Remove DefaultHttpDataSourceFactory. Use DefaultHttpDataSource.Factory instead.
      • Remove SingleSampleMediaSource.createMediaSource(Uri, Format, long). Use SingleSampleMediaSource.createMediaSource(MediaItem.Subtitle, long) instead.
      • Remove HttpDataSource.Factory.getDefaultRequestProperties. Use HttpDataSource.Factory.setDefaultRequestProperties instead.
      • Remove GvrAudioProcessor and the GVR extension, which has been deprecated since 2.11.0.
      • Remove DownloadService.onDownloadChanged and DownloadService.onDownloadRemoved. Instead, use DownloadManager.addListener to register a listener directly to the DownloadManager returned through DownloadService.getDownloadManager.
      • Remove Player.getCurrentStaticMetadata, Player.Listener.onStaticMetadataChanged and Player.EVENT_STATIC_METADATA_CHANGED. Use Player.getMediaMetadata, Player.Listener.onMediaMetadataChanged and Player.EVENT_MEDIA_METADATA_CHANGED for convenient access to structured metadata, or access the raw static metadata directly from the TrackSelection#getFormat().
      • Remove ControlDispatcher and DefaultControlDispatcher. Operations can be customized by using a ForwardingPlayer, or when configuring the player (for example by using ExoPlayer.Builder.setSeekBackIncrementMs).
    Source code(tar.gz)
    Source code(zip)
  • r2.15.1(Sep 22, 2021)

    • Core Library:
      • Fix track selection in StyledPlayerControlView when using ForwardingPlayer.
      • Fix FlagSet#equals on API levels below 24.
      • Fix NullPointerException being thrown from CacheDataSource when reading a fully cached resource with DataSpec.position equal to the resource length.
      • Fix a bug when depending on ExoPlayer locally with a relative path (#9403).
      • Better handle invalid seek requests. Seeks to positions that are before the start or after the end of the media are now handled as seeks to the start and end respectively (8906).
      • Rename MimeTypes.AUDIO_DTS_UHD to MimeTypes.AUDIO_DTS_X and add required profile to its value (#9429).
    • Extractors:
      • Support TS packets without PTS flag (#9294).
      • Fix issue decoding ID3 tags containing UTF-16 encoded strings (#9087).
    • Video:
      • Request smaller decoder input buffers for Dolby Vision. This fixes an issue that could cause UHD Dolby Vision playbacks to fail on some devices, including Amazon Fire TV 4K.
    • DRM:
      • Fix DefaultDrmSessionManager to correctly eagerly release preacquired DRM sessions when there's a shortage of DRM resources on the device.
    • Downloads and caching:
      • Workaround platform issue that can cause a SecurityException to be thrown from Requirements.isInternetConnectivityValidated on devices running Android 11 (#9002).
    • DASH:
      • Use identical cache keys for downloading and playing DASH segments (#9370).
      • Fix base URL selection and load error handling when base URLs are shared across adaptation sets.
    • HLS:
      • Fix bug where the player would get stuck if all download attempts fail and would not raise an error to the application (#9390).
    • RTSP:
      • Handle when additional spaces are in SDP's RTPMAP atrribute (#9379).
      • Handle partial URIs in RTP-Info headers (#9346).
      • Fix RTSP Session header handling (#9416).
      • Fix RTSP WWW-Authenticate header parsing (#9428).
    • UI:
      • Use defStyleAttr when obtaining styled attributes in StyledPlayerView, PlayerView and PlayerControlView (#9024).
      • Fix accessibility focus in PlayerControlView (#9111).
      • Fix issue that StyledPlayerView and PlayerView don't update UI when available player commands change.
    • Cast extension:
      • Implement CastPlayer.setPlaybackParameters(PlaybackParameters) to support setting the playback speed (#6784).
    Source code(tar.gz)
    Source code(zip)
  • r2.15.0(Aug 11, 2021)

    • Core Library:
      • Add MediaCodecAdapter.needsReconfiguration method.
      • Add getSeekBackIncrement, seekBack, getSeekForwardIncrement, seekForward, getMaxSeekToPreviousPosition, seekToPrevious and seekToNext methods to Player.
      • Rename Player methods:
        • hasPrevious to hasPreviousWindow.
        • previous to seekToPreviousWindow.
        • hasNext to hasNextWindow.
        • next to seekToNextWindow.
      • Rename Player commands:
        • COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM to COMMAND_SEEK_IN_CURRENT_WINDOW.
        • COMMAND_SEEK_TO_NEXT_MEDIA_ITEM to COMMAND_SEEK_TO_NEXT_WINDOW.
        • COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM to COMMAND_SEEK_TO_PREVIOUS_WINDOW.
        • COMMAND_SEEK_TO_MEDIA_ITEM to COMMAND_SEEK_TO_WINDOW.
        • COMMAND_GET_MEDIA_ITEMS to COMMAND_GET_TIMELINE.
      • Rename Player.EventFlags IntDef to Player.Event.
      • Make Player depend on the new PlaybackException class instead of ExoPlaybackException:
        • Player.getPlayerError now returns a PlaybackException.
        • Player.Listener.onPlayerError now receives a PlaybackException.
        • Add a new listener method Player.Listener.onPlayerErrorChanged, which is equivalent to onPlayerError except that it is also called when the player error becomes null.
        • Player implementations like ExoPlayer may use PlaybackException subclasses (like ExoPlaybackException), so users can downcast the PlaybackException instance to obtain implementation-specific fields (like ExoPlaybackException.rendererIndex).
      • PlaybackException introduces an errorCode which identifies the cause of the failure in order to simplify error handling (#1611).
      • Add a DefaultMediaDescriptionAdapter for the PlayerNotificationManager, that makes use of the Player MediaMetadata to populate the notification fields.
      • Add @FallbackType to LoadErrorHandlingPolicy to support customization of the exclusion duration for locations and tracks.
      • Change interface of LoadErrorHandlingPolicy to support configuring the behavior of track and location fallback. Location fallback is currently only supported for DASH manifests with multiple base URLs.
      • Restrict use of AudioTrack.isDirectPlaybackSupported to TVs, to avoid listing audio offload encodings as supported for passthrough mode on mobile devices (#9239).
    • Extractors:
      • Add support for DTS-UHD in MP4 (#9163).
    • Text:
      • TTML: Inherit the rubyPosition value from a containing <span ruby="container"> element.
      • WebVTT: Add support for CSS font-size property (#8964).
    • Ad playback:
      • Support changing ad break positions in the player logic (#5067).
      • Support resuming content with an offset after an ad group.
    • UI:
      • Add setUseRewindAction and setUseFastForwardAction to PlayerNotificationManager, and setUseFastForwardActionInCompactView and setUseRewindActionInCompactView to show the actions in compact view mode.
      • Remove rewind_increment and fastforward_increment attributes from PlayerControlView and StyledPlayerControlView. These increments can be customized by configuring the Player (see setSeekBackIncrementMs and setSeekForwardIncrementMs in SimpleExoPlayer.Builder), or by using a ForwardingPlayer that overrides getSeekBackIncrement, seekBack, getSeekForwardIncrement and seekForward. The rewind and fast forward buttons can be disabled by using a ForwardingPlayer that removes COMMAND_SEEK_BACK and COMMAND_SEEK_FORWARD from the available commands.
      • Update DefaultControlDispatcher getRewindIncrementMs and getFastForwardIncrementMs to take the player as parameter.
    • DASH:
      • Add support for multiple base URLs and DVB attributes in the manifest. Apps that are using DefaultLoadErrorHandlingPolicy with such manifests have base URL fallback automatically enabled (#771, #7654).
    • HLS:
      • Fix issue that could cause some playbacks to be stuck buffering (#8850, #9153).
      • Report audio track type in AnalyticsListener.onDownstreamFormatChanged() for audio-only playlists, so that the PlaybackStatsListener can derive audio format-related information (#9175).
    • RTSP:
      • Use standard RTSP header names (#9182).
      • Handle an extra semicolon in SDP fmtp attribute (#9247).
      • Fix handling of special characters in the RTSP session ID (#9254).
    • SmoothStreaming:
      • Propagate StreamIndex element Name attribute value as Format label (#9252).
    • Cronet extension:
      • Add CronetDataSource.Factory.setRequestPriority to allow setting the priority of requests made by CronetDataSource instances.
    • OkHttp extension:
      • Switch to OkHttp 4.9.1. This increases the extension's minimum SDK version requirement from 16 to 21.
    • Remove deprecated symbols:
      • Remove CastPlayer specific playlist manipulation methods. Use setMediaItems, addMediaItems, removeMediaItem and moveMediaItem instead.
      • Remove Format.create methods. Use Format.Builder instead.
      • Remove MediaSource.getTag. Use MediaSource.getMediaItem and MediaItem.PlaybackProperties.tag instead.
      • Remove PlaybackPreparer. UI components that previously had setPlaybackPreparer methods will now call Player.prepare by default. If this behavior is sufficient, use of PlaybackPreparer can be removed from application code without replacement. For custom preparation logic, use a ForwardingPlayer that implements custom preparation logic in prepare.
      • Remove Player.Listener.onTimelineChanged(Timeline, Object, int). Use Player.Listener.onTimelineChanged(Timeline, int) instead. The manifest can be accessed using Player.getCurrentManifest.
      • Remove Player.getCurrentTag. Use Player.getCurrentMediaItem and MediaItem.PlaybackProperties.tag instead.
      • Remove Player.getPlaybackError. Use Player.getPlayerError instead.
      • Remove PlayerNotificationManager constructors and createWith methods. Use PlayerNotificationManager.Builder instead.
      • Remove PlayerNotificationManager.setNotificationListener. Use PlayerNotificationManager.Builder.setNotificationListener instead.
      • Remove PlayerNotificationManager setUseNavigationActions and setUseNavigationActionsInCompactView. Use setUseNextAction, setUsePreviousAction, setUseNextActionInCompactView and setUsePreviousActionInCompactView instead.
      • Remove setRewindIncrementMs and setFastForwardIncrementMs from UI components. These increments can be customized by configuring the Player (see setSeekBackIncrementMs and setSeekForwardIncrementMs in SimpleExoPlayer.Builder), or by using a ForwardingPlayer that overrides getSeekBackIncrement, seekBack, getSeekForwardIncrement and seekForward. The rewind and fast forward buttons can be disabled by using a ForwardingPlayer that removes COMMAND_SEEK_BACK and COMMAND_SEEK_FORWARD from the available commands.
      • Remove Timeline.getWindow(int, Window, boolean). Use Timeline.getWindow(int, Window) instead, which will always set tags.
    Source code(tar.gz)
    Source code(zip)
  • r2.14.2(Jul 21, 2021)

    • Core Library:
      • Explicitly mark several methods on SimpleExoPlayer as @Deprecated. These methods are all overrides and are already deprecated on Player and the respective ExoPlayer component classes (since 2.14.0).
    • Video:
      • Fix IncorrectContextUseViolation strict mode warning on Android 11 (#8246).
    • Audio:
      • Fix track selection for E-AC-3 streams.
      • Use AudioTrack.isDirectPlaybackSupported to check for encoded audio passthrough capability from API 29 onwards, instead of using the HDMI audio plug intent (#6500).
    • Extractors:
      • Fix issue where a trun atom could be associated with the wrong track in an FMP4 stream (#9056). The fix removes a previous workaround to handle content in which the track_ID is set incorrectly (#4083). Such content is malformed and should be re-encoded.
      • Improve support for truncated Ogg streams (#7608).
      • Add support for MP4 H263 atom type (#9158).
      • Fix issue around TS synchronization when reading a file's duration (#9100).
    • HLS:
      • Fix issue where playback of a live event could become stuck rather than transitioning to STATE_ENDED when the event ends (#9067).
      • Fix issue where a new initialization segment, as specified by an EXT-X-MAP tag in a media playlist, would not be loaded when encountered during playback (#9004).
      • Forward the FRAME-RATE value from the master playlist to renditions (#8960).
      • Fix issue where HLS events would start at positions greater than specified by an EXT-X-START tag when placed in a playlist (#9037).
    • Ad playback:
      • Use the content URI when auto-generating an ad ID (in addition to the media ID and ad tag URI) (#9106.
    • DRM:
      • Allow repeated provisioning in DefaultDrmSession(Manager).
      • Fix a crash due to DefaultDrmSessionManager.release() incorrectly releasing too many keep-alive DefaultDrmSession references, resulting in DefaultDrmSession.release() throwing an IllegalStateException (#9193).
    • Metadata:
      • Fix handling of emsg messages with an unset duration (#9123).
    • UI:
      • Add PendingIntent.FLAG_IMMUTABLE flag when creating a broadcast intent in PlayerNotificationManager. This is required to avoid an error on Android 12.
      • Fix focusability of StyledPlayerView and StyledPlayerControlView popup menus on API levels prior to 26 (#9061).
      • Fix progress bar flickering immediately after the user seeks (#9049).
      • Fix StyledPlayerView and StyledPlayerControlView popup menu items not expanding to occupy the full width of the popup (#9086).
      • Don't propagate AttributeSet from SubtitleView constructor into CanvasSubtitleOutput. Just passing the Context is enough, and ensures programmatic changes to the SubtitleView will propagate down.
    • RTSP:
      • Fix session description (SDP) parsing to use a HashMap-like behaviour for duplicated attributes (#9014).
      • Allow using absolute URI in the control attribute in a media description (#9183).
      • Allow the timeout to be customised via RtspMediaSource.Factory.setTimeoutMs.
    Source code(tar.gz)
    Source code(zip)
  • r2.14.1(Jun 14, 2021)

    • Core Library:
      • Fix gradle config to allow specifying a relative path for exoplayerRoot when depending on ExoPlayer locally (#8927).
      • Update MediaItem.Builder javadoc to discourage calling setters that will be (currently) ignored if another setter is not also called.
    • Extractors:
      • Add support for MPEG-H 3D Audio in MP4 extractors (#8860).
    • Video:
      • Fix bug that could cause CodecException: Error 0xffffffff to be thrown from MediaCodec.native_setSurface in use cases that involve both swapping the output Surface and a mixture of secure and non-secure content being played (#8776).
    • HLS:
      • Use the PRECISE attribute in EXT-X-START to select the default start position.
      • Fix a bug where skipping into spliced-in chunks triggered an assertion error (#8937).
    • DRM:
      • Keep secure MediaCodec instances initialized when disabling (but not resetting) MediaCodecRenderer. This helps re-use secure decoders in more contexts, which avoids the 'black flash' caused by detaching a Surface from a secure decoder on some devices (#8842). It will also result in DRM license refresh network requests while the player is stopped if Player#setForegroundMode is true.
      • Fix issue where offline keys were unnecessarily (and incorrectly) restored into a session before being released. This call sequence is explicitly disallowed in OEMCrypto v16.
    • UI:
      • Keep subtitle language features embedded (e.g. rubies & tate-chu-yoko) in Cue.text even when SubtitleView#setApplyEmbeddedStyles() is false.
      • Fix NullPointerException in StyledPlayerView that could occur after calling StyledPlayerView.setPlayer(null) (#8985).
    • RTSP:
      • Add support for RTSP basic and digest authentication (#8941).
      • Enable using repeat mode and playlist with RTSP (#8994).
      • Add RtspMediaSource.Factory option to set the RTSP user agent.
      • Add RtspMediaSource.Factory option to force using TCP for streaming.
    • GL demo app:
      • Fix texture transformation to avoid green bars shown on some videos (#8992).
    Source code(tar.gz)
    Source code(zip)
  • r2.14.0(May 14, 2021)

    • Core Library:
      • Move Player components to ExoPlayer. For example Player.VideoComponent is now ExoPlayer.VideoComponent.
      • The most used methods of Player's audio, video, text and metadata components have been added directly to Player.
      • Add Player.getAvailableCommands, Player.isCommandAvailable and Listener.onAvailableCommandsChanged to query which commands that can be executed on the player.
      • Add a Player.Listener interface to receive all player events. Component listeners and EventListener have been deprecated.
      • Add Player.getMediaMetadata, which returns a combined and structured MediaMetadata object. Changes to metadata are reported to Listener.onMediaMetadataChanged.
      • Player.setPlaybackParameters no longer accepts null, use PlaybackParameters.DEFAULT instead.
      • Report information about the old and the new playback positions to Listener.onPositionDiscontinuity. Add DISCONTINUITY_REASON_SKIP and DISCONTINUITY_REASON_REMOVE as discontinuity reasons, and rename DISCONTINUITY_REASON_PERIOD_TRANSITION to DISCONTINUITY_REASON_AUTO_TRANSITION. Remove DISCONTINUITY_REASON_AD_INSERTION, for which DISCONTINUITY_REASON_AUTO_TRANSITION is used instead (#6163, #4768).
      • Deprecate ExoPlayer.Builder. Use SimpleExoPlayer.Builder instead.
      • Move Player.getRendererCount and Player.getRendererType to ExoPlayer.
      • Use an empty string instead of the URI if the media ID is not explicitly set with MediaItem.Builder.setMediaId(String).
      • Remove MediaCodecRenderer.configureCodec() and add MediaCodecRenderer.getMediaCodecConfiguration(). The new method is called just before the MediaCodec is created and returns the parameters needed to create and configure the MediaCodec instance. Applications can override MediaCodecRenderer.onCodecInitialized() to be notified after a MediaCodec is initialized, or they can inject a custom MediaCodecAdapter.Factory if they want to control how the MediaCodec is configured.
      • Promote AdaptiveTrackSelection.AdaptationCheckpoint to public visibility to allow Kotlin subclasses of AdaptiveTrackSelection.Factory (#8830).
      • Fix bug when transitions from content to ad periods called onMediaItemTransition by mistake.
      • AdsLoader.AdViewProvider and AdsLoader.OverlayInfo have been renamed com.google.android.exoplayer2.ui.AdViewProvider and com.google.android.exoplayer2.ui.AdOverlayInfo respectively.
      • CaptionStyleCompat has been moved to the com.google.android.exoplayer2.ui package.
      • DebugTextViewHelper has been moved from the ui package to the util package.
    • RTSP:
      • Initial support for RTSP playbacks (#55).
    • Downloads and caching:
      • Fix CacheWriter to correctly handle cases where the request DataSpec extends beyond the end of the underlying resource. Caching will now succeed in this case, with data up to the end of the resource being cached. This behaviour is enabled by default, and so the allowShortContent parameter has been removed (#7326).
      • Fix CacheWriter to correctly handle DataSource.close failures, for which it cannot be assumed that data was successfully written to the cache.
    • DRM:
      • Prepare DRM sessions (and fetch keys) ahead of the playback position (#4133).
      • Only dispatch DRM session acquire and release events once per period when playing content that uses the same encryption keys for both audio & video tracks. Previously, separate acquire and release events were dispatched for each track in each period.
      • Include the session state in DRM session-acquired listener methods.
    • UI:
      • Add PlayerNotificationManager.Builder, with the ability to specify which group the notification should belong to.
      • Remove setUseSensorRotation from PlayerView and StyledPlayerView. Instead, cast the view returned by getVideoSurfaceView to SphericalGLSurfaceView, and then call setUseSensorRotation on the SphericalGLSurfaceView directly.
    • Analytics:
      • Add onAudioCodecError and onVideoCodecError to AnalyticsListener.
    • Video:
      • Add Player.getVideoSize() to retrieve the current size of the video stream. Add Listener.onVideoSizeChanged(VideoSize) and deprecate Listener.onVideoSizeChanged(int, int, int, float).
    • Audio:
      • Report unexpected audio discontinuities to AnalyticsListener.onAudioSinkError (#6384).
      • Allow forcing offload for gapless content even if gapless playback is not supported.
      • Allow fall back from DTS-HD to DTS when playing via passthrough.
    • Text:
      • Fix overlapping lines when using SubtitleView.VIEW_TYPE_WEB.
      • Parse SSA/ASS underline & strikethrough info in Style: lines (#8435).
      • Ensure TTML tts:textAlign is correctly propagated from <p> nodes to child nodes.
      • Support TTML ebutts:multiRowAlign attributes.
    • Allow the use of Android platform extractors through MediaParser:
      • Supported on API 30+:
      • You can use platform extractors for progressive media by passing MediaParserExtractorAdapter.FACTORY when creating a ProgressiveMediaSource.Factory.
      • You can use platform extractors for HLS by passing MediaParserHlsMediaChunkExtractor.FACTORY when creating a HlsMediaSource.Factory.
      • You can use platform extractors for DASH by passing a DefaultDashChunkSource that uses MediaParserChunkExtractor.FACTORY when creating a DashMediaSource.Factory.
    • Cast extension:
      • Trigger onMediaItemTransition event for all reasons except MEDIA_ITEM_TRANSITION_REASON_REPEAT.
    • MediaSession extension:
      • Remove dependency on exoplayer-core, relying only exoplayer-common instead. To achieve this, TimelineQueueEditor uses a new MediaDescriptionConverter interface, and no longer relies on ConcatenatingMediaSource.
    • Remove deprecated symbols:
      • Remove ExoPlayerFactory. Use SimpleExoPlayer.Builder instead.
      • Remove Player.DefaultEventListener. Use Player.Listener instead.
      • Remove ExtractorMediaSource. Use ProgressiveMediaSource instead.
      • Remove DefaultMediaSourceEventListener. Use MediaSourceEventListener instead.
      • Remove DashManifest constructor. Use the remaining constructor with programInformation and serviceDescription set to null instead.
      • Remove CryptoInfo.getFrameworkCryptoInfoV16. Use CryptoInfo.getFrameworkCryptoInfo instead.
      • Remove NotificationUtil.createNotificationChannel(Context, String, int, int). Use createNotificationChannel(Context, String, int, int, int) instead.
      • Remove PlayerNotificationManager.setNotificationListener. Use PlayerNotificationManager.Builder.setNotificationListener instead.
      • Remove PlayerNotificationManager.NotificationListener onNotificationStarted(int, Notification) and onNotificationCancelled(int). Use onNotificationPosted(int, Notification, boolean) and onNotificationCancelled(int, boolean) instead.
      • Remove DownloadNotificationUtil. Use DownloadNotificationHelper instead.
      • Remove extension-jobdispatcher module. Use the extension-workmanager module instead.
    Source code(tar.gz)
    Source code(zip)
  • r2.13.3(Apr 14, 2021)

    • Published via the Google Maven repository (i.e., google()) rather than JCenter.
    • Core:
      • Reset playback speed when live playback speed control becomes unused (#8664).
      • Fix playback position issue when re-preparing playback after a BehindLiveWindowException (#8675).
      • Assume Dolby Vision content is encoded as H264 when calculating maximum codec input size (#8705).
    • UI:
      • Fix StyledPlayerView scrubber not reappearing correctly in some cases (#8646).
      • Fix measurement of StyledPlayerView and StyledPlayerControlView when wrap_content is used (#8726).
      • Fix StyledPlayerControlView to stay in full mode (rather than minimal mode) when possible (#8763).
    • DASH:
      • Parse forced_subtitle role from DASH manifests (#8781).
    • HLS:
      • Fix bug of ignoring EXT-X-START when setting the live target offset (#8764).
      • Fix incorrect application of byte ranges to EXT-X-MAP tags (#8783).
      • Fix issue that could cause playback to become stuck if corresponding EXT-X-DISCONTINUITY tags in different media playlists occur at different positions in time (#8372).
      • Fix issue that could cause playback of on-demand content to not start in cases where the media playlists referenced by the master playlist have different starting EXT-X-PROGRAM-DATE-TIME tags.
      • Fix container type detection for segments with incorrect file extension or HTTP Content-Type (#8733).
    • Extractors:
      • Add support for GContainer and GContainerItem XMP namespace prefixes in JPEG motion photo parsing.
      • Allow JFIF APP0 marker segment preceding Exif APP1 segment in JpegExtractor.
    • Text:
      • Parse SSA/ASS bold & italic info in Style: lines (#8435).
      • Don't display subtitles after the end position of the current media period (if known). This ensures sideloaded subtitles respect the end point of ClippingMediaPeriod and prevents content subtitles from continuing to be displayed over mid-roll ads (#5317, #8456).
      • Fix CEA-708 priority handling to sort cues in the order defined by the spec (#8704).
      • Support TTML textEmphasis attributes, used for Japanese boutens.
      • Support TTML shear attributes.
    • Metadata:
      • Ensure that timed metadata near the end of a period is not dropped (#8710).
    • Cast extension:
      • Fix onPositionDiscontinuity event so that it is not triggered with reason DISCONTINUITY_REASON_PERIOD_TRANSITION after a seek to another media item and so that it is not triggered after a timeline change.
    • IMA extension:
      • Fix error caused by AdPlaybackState ad group times being cleared, which can occur if the ImaAdsLoader is released while an ad is pending loading (#8693).
      • Upgrade IMA SDK dependency to 3.23.0, fixing an issue with NullPointerExceptions within WebView callbacks (#8447).
    • FFmpeg extension: Fix playback failure when switching to TrueHD tracks during playback (#8616).
    Source code(tar.gz)
    Source code(zip)
  • r2.13.2(Feb 25, 2021)

    • Extractors:
      • Add support for MP4 and QuickTime meta atoms that are not full atoms.
    • UI:
      • Make conditions to enable UI actions consistent in DefaultControlDispatcher, PlayerControlView, StyledPlayerControlView, PlayerNotificationManager and TimelineQueueNavigator.
      • Fix conditions to enable seeking to next/previous media item to handle the case where a live stream has ended.
    • Audio:
      • Fix SimpleExoPlayer reporting audio session ID as 0 in some cases (#8585).
    • IMA extension:
      • Fix a bug where playback could get stuck when seeking into a playlist item with ads, if the preroll ad had preloaded but the window position of the seek should instead trigger playback of a midroll.
      • Fix a bug with playback of ads in playlists, where the incorrect period index was used when deciding whether to trigger playback of an ad after a seek.
    • Text:
      • Parse SSA/ASS font size in Style: lines (#8435).
    • VP9 extension: Update to use NDK r21 (#8581).
    • FLAC extension: Update to use NDK r21 (#8581).
    • Opus extension: Update to use NDK r21 (#8581).
    • FFmpeg extension: Update to use NDK r21 (#8581).
    Source code(tar.gz)
    Source code(zip)
  • r2.13.1(Feb 13, 2021)

    • Live streaming:
      • Fix playback issue for HLS live streams without program date time information (#8560).
      • Fix playback issue for multi-period DASH live streams (#8537).
      • Fix playback failures when playing live streams with video tunneling enabled (#8570).
    • IMA extension:
      • Fix handling of repeated ad loads, to avoid ads being discarded if the user seeks away and then back to a preloaded postroll (for example).
      • Fix a bug where an assertion would fail if the player started to buffer an ad media period before the ad URI was known then an ad state update arrived that didn't set the ad URI.
      • Add ImaAdsLoader.focusSkipButton to allow apps to request that the skip button should receive UI focus, if shown (#8565).
    • DRM:
      • Re-use the previous DrmSessionManager instance when playing a playlist (if possible) (#8523).
      • Propagate DRM configuration when creating media sources for ad content (#8568).
      • Only release 'keepalive' references to DrmSession in DefaultDrmSessionManager#release() if keepalive is enabled (#8576).
    Source code(tar.gz)
    Source code(zip)
  • r2.13.0(Feb 5, 2021)

    • Core library:
      • Verify correct thread usage in SimpleExoPlayer by default. Opt-out is still possible until the next major release using setThrowsWhenUsingWrongThread(false) (#4463).
      • Add Player.getCurrentStaticMetadata and EventListener.onStaticMetadataChanged to expose static metadata belonging to the currently playing stream (#7266).
      • Add PlayerMessage.setLooper and deprecate PlayerMessage.setHandler.
      • Add option to MergingMediaSource to clip the durations of all sources to have the same length (#8422).
      • Remove Player.setVideoDecoderOutputBufferRenderer from Player API. Use setVideoSurfaceView and clearVideoSurfaceView instead.
      • Default SingleSampleMediaSource.treatLoadErrorsAsEndOfStream to true so that errors loading external subtitle files do not cause playback to fail (#8430). A warning will be logged by SingleSampleMediaPeriod whenever a load error is treated as though the end of the stream has been reached.
      • Time out on release to prevent ANRs if an underlying platform call is stuck (#4352).
      • Time out when detaching a surface to prevent ANRs if the underlying platform call is stuck (#5887).
      • Fix bug where AnalyticsListener callbacks could arrive in the wrong order (#8048).
    • Media transformation:
      • Add a new transformer module for converting media streams. The initially available transformations are changing the container format, removing tracks, and slow motion flattening.
    • Low latency live streaming:
      • Support low-latency DASH (also known as ULL-CMAF) and Apple's low-latency HLS extension.
      • Add LiveConfiguration to MediaItem to define live offset and playback speed adjustment parameters. The same parameters can be set on DefaultMediaSourceFactory to apply for all MediaItems.
      • Add LivePlaybackSpeedControl to control playback speed adjustments during live playbacks. Such adjustments allow the player to stay close to the live offset. DefaultLivePlaybackSpeedControl is provided as a default implementation.
      • Add targetLiveOffsetUs parameter to LoadControl.shouldStartPlayback.
    • Extractors:
      • Populate codecs string for H.264/AVC in MP4, Matroska and FLV streams to allow decoder capability checks based on codec profile and level (#8393).
      • Populate codecs string for H.265/HEVC in MP4, Matroska and MPEG-TS streams to allow decoder capability checks based on codec profile and level (#8393).
      • Add support for playing JPEG motion photos (#5405).
      • Handle sample size mismatches between raw audio stsd information and stsz fixed sample size in MP4 extractors.
      • Fix Vorbis private codec data parsing in the Matroska extractor (#8496).
    • Track selection:
      • Move Player.getTrackSelector to the ExoPlayer interface.
      • Move the mutable parts of TrackSelection into an ExoTrackSelection subclass.
      • Allow parallel adaptation of video and audio (#5111).
      • Simplify enabling tunneling with DefaultTrackSelector. ParametersBuilder.setTunnelingAudioSessionId has been replaced with ParametersBuilder.setTunnelingEnabled. The player's audio session ID will be used, and so a tunneling specific ID is no longer needed.
      • Add additional configuration parameters to DefaultTrackSelector. DefaultTrackSelector.ParametersBuilder now includes:
        • setPreferredVideoMimeType, setPreferredVideoMimeTypes, setPreferredAudioMimeType and setPreferredAudioMimeTypes for specifying preferred video and audio MIME type(s) (#8320).
        • setPreferredAudioLanguages and setPreferredTextLanguages for specifying multiple preferred audio and text languages.
        • setPreferredAudioRoleFlags for specifying preferred audio role flags.
      • Forward Timeline and MediaPeriodId to TrackSelection.Factory.
    • DASH:
      • Support low-latency DASH playback (availabilityTimeOffset and ServiceDescription tags) (#4904).
      • Improve logic for determining whether to refresh the manifest when a chunk load error occurs in a live streams that contains EMSG data (#8408).
    • HLS:
      • Support playlist delta updates, blocking playlist reloads and rendition reports.
      • Support low-latency HLS playback (EXT-X-PART and preload hints) (#5011).
    • UI:
      • Improve StyledPlayerControlView button animations.
      • Miscellaneous fixes for StyledPlayerControlView in minimal mode.
    • DRM:
      • Fix playback failure when switching from PlayReady protected content to Widevine or Clearkey protected content in a playlist.
      • Add ExoMediaDrm.KeyRequest.getRequestType (#7847).
      • Drop key and provision responses if DefaultDrmSession is released while waiting for the response. This prevents harmless log messages of the form: IllegalStateException: sending message to a Handler on a dead thread (#8328).
      • Allow apps to fully customize DRM behaviour for each MediaItem by passing a DrmSessionManagerProvider to MediaSourceFactory (#8466).
    • Analytics:
      • Add an onEvents callback to Player.EventListener and AnalyticsListener. When one or more player states change simultaneously, onEvents is called once after all of the callbacks associated with the individual state changes.
      • Pass a DecoderReuseEvaluation to AnalyticsListener's onVideoInputFormatChanged and onAudioInputFormatChanged methods. The DecoderReuseEvaluation indicates whether it was possible to re-use an existing decoder instance for the new format, and if not then the reasons why.
    • Video:
      • Fall back to AVC/HEVC decoders for Dolby Vision streams with level 10 to 13 (#8530).
      • Fix VP9 format capability checks on API level 23 and earlier. The platform does not correctly report the VP9 level supported by the decoder in this case, so we estimate it based on the decoder's maximum supported bitrate.
    • Audio:
      • Fix handling of audio session IDs (#8190). SimpleExoPlayer now generates an audio session ID on construction, which can be immediately queried by calling SimpleExoPlayer.getAudioSessionId. The audio session ID will only change if application code calls SimpleExoPlayer.setAudioSessionId.
      • Replace onAudioSessionId with onAudioSessionIdChanged in AudioListener and AnalyticsListener. Note that onAudioSessionIdChanged is called in fewer cases than onAudioSessionId was called, due to the improved handling of audio session IDs as described above.
      • Retry playback after some types of AudioTrack error.
      • Create E-AC3 JOC passthrough AudioTrack instances using the maximum supported channel count (instead of assuming 6 channels) from API 29.
    • Text:
      • Add support for the SSA primaryColour style attribute (#8435).
      • Fix CEA-708 sequence number discontinuity handling (#1807).
      • Fix CEA-708 handling of unexpectedly small packets (#1807).
    • Data sources:
      • For HttpDataSource implementations, default to using the user agent of the underlying network stack.
      • Deprecate HttpDataSource.Factory.getDefaultRequestProperties. HttpDataSource.Factory.setDefaultRequestProperties instead.
      • Add DefaultHttpDataSource.Factory and deprecate DefaultHttpDataSourceFactory.
    • Metadata retriever:
      • Parse Google Photos HEIC and JPEG motion photo metadata.
    • IMA extension:
      • Add support for playback of ads in playlists (#3750).
      • Add ImaAdsLoader.Builder.setEnableContinuousPlayback for setting whether to request ads for continuous playback.
      • Upgrade IMA SDK dependency to 3.22.0. This fixes leaking of the ad view group (#7344, #8339).
      • Fix a bug that could cause the next content position played after a seek to snap back to the cue point of the preceding ad, rather than the requested content position.
      • Fix a regression that caused an ad group to be skipped after an initial seek to a non-zero position. Unsupported VPAID ads will still be skipped, but only after the preload timeout rather than instantly (#8428, #7832).
      • Fix a regression that caused a short ad followed by another ad to be skipped due to playback being stuck buffering waiting for the second ad to load (#8492).
    • FFmpeg extension:
      • Link the FFmpeg library statically, saving 350KB in binary size on average.
    • OkHttp extension:
      • Add OkHttpDataSource.Factory and deprecate OkHttpDataSourceFactory.
    • Cronet extension:
      • Add CronetDataSource.Factory and deprecate CronetDataSourceFactory.
      • Support setting the user agent on CronetDataSource.Factory and CronetEngineWrapper.
    • MediaSession extension:
      • Support setPlaybackSpeed(float) and disable it by default. Use MediaSessionConnector.setEnabledPlaybackActions(long) to enable (#8229).
    • Remove deprecated symbols:
      • AdaptiveMediaSourceEventListener. Use MediaSourceEventListener instead.
      • DashMediaSource.Factory.setMinLoadableRetryCount(int). Use DashMediaSource.Factory.setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy) instead.
      • DefaultAnalyticsListener. Use AnalyticsListener instead.
      • DefaultLoadControl constructors. Use DefaultLoadControl.Builder instead.
      • DrmInitData.get(UUID). Use DrmInitData.get(int) and DrmInitData.SchemeData.matches(UUID) instead.
      • ExtractorsMediaSource.Factory.setMinLoadableRetryCount(int). Use ExtractorsMediaSource.Factory.setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy) instead.
      • FixedTrackSelection.Factory. If you need to disable adaptive selection in DefaultTrackSelector, enable the DefaultTrackSelector.Parameters.forceHighestSupportedBitrate flag.
      • HlsMediaSource.Factory.setMinLoadableRetryCount(int). Use HlsMediaSource.Factory.setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy) instead.
      • MappedTrackInfo.getTrackFormatSupport(int, int, int). Use MappedTrackInfo.getTrackSupport(int, int, int) instead.
      • MappedTrackInfo.getTrackTypeRendererSupport(int). Use MappedTrackInfo.getTypeSupport(int) instead.
      • MappedTrackInfo.getUnassociatedTrackGroups(). Use MappedTrackInfo.getUnmappedTrackGroups() instead.
      • MappedTrackInfo.length. Use MappedTrackInfo.getRendererCount() instead.
      • Player.DefaultEventListener.onTimelineChanged(Timeline, Object). Use Player.EventListener.onTimelineChanged(Timeline, int) instead.
      • Player.setAudioAttributes(AudioAttributes). Use Player.AudioComponent.setAudioAttributes(AudioAttributes, boolean) instead.
      • PlayerView.setDefaultArtwork(Bitmap). Use PlayerView.setDefaultArtwork(Drawable) instead.
      • PlayerView.setShowBuffering(boolean). Use PlayerView.setShowBuffering(int) instead.
      • SimpleExoPlayer.clearMetadataOutput(MetadataOutput). Use SimpleExoPlayer.removeMetadataOutput(MetadataOutput) instead.
      • SimpleExoPlayer.clearTextOutput(TextOutput). Use SimpleExoPlayer.removeTextOutput(TextOutput) instead.
      • SimpleExoPlayer.clearVideoListener(). Use SimpleExoPlayer.removeVideoListener(VideoListener) instead.
      • SimpleExoPlayer.getAudioStreamType(). Use SimpleExoPlayer.getAudioAttributes() instead.
      • SimpleExoPlayer.setAudioDebugListener(AudioRendererEventListener). Use SimpleExoPlayer.addAnalyticsListener(AnalyticsListener) instead.
      • SimpleExoPlayer.setAudioStreamType(int). Use SimpleExoPlayer.setAudioAttributes(AudioAttributes) instead.
      • SimpleExoPlayer.setMetadataOutput(MetadataOutput). Use SimpleExoPlayer.addMetadataOutput(MetadataOutput) instead. If your application is calling SimpleExoPlayer.setMetadataOutput(null), make sure to replace this call with a call to SimpleExoPlayer.removeMetadataOutput(MetadataOutput).
      • SimpleExoPlayer.setPlaybackParams(PlaybackParams). Use SimpleExoPlayer.setPlaybackParameters(PlaybackParameters) instead.
      • SimpleExoPlayer.setTextOutput(TextOutput). Use SimpleExoPlayer.addTextOutput(TextOutput) instead. If your application is calling SimpleExoPlayer.setTextOutput(null), make sure to replace this call with a call to SimpleExoPlayer.removeTextOutput(TextOutput).
      • SimpleExoPlayer.setVideoDebugListener(VideoRendererEventListener). Use SimpleExoPlayer.addAnalyticsListener(AnalyticsListener) instead.
      • SimpleExoPlayer.setVideoListener(VideoListener). Use SimpleExoPlayer.addVideoListener(VideoListener) instead. If your application is calling SimpleExoPlayer.setVideoListener(null), make sure to replace this call with a call to SimpleExoPlayer.removeVideoListener(VideoListener).
      • SimpleExoPlayer.VideoListener. Use com.google.android.exoplayer2.video.VideoListener instead.
      • SingleSampleMediaSource.EventListener and constructors. Use MediaSourceEventListener and SingleSampleMediaSource.Factory instead.
      • SimpleExoPlayer.addVideoDebugListener, SimpleExoPlayer.removeVideoDebugListener, SimpleExoPlayer.addAudioDebugListener and SimpleExoPlayer.removeAudioDebugListener. Use SimpleExoPlayer.addAnalyticsListener and SimpleExoPlayer.removeAnalyticsListener instead.
      • SingleSampleMediaSource.Factory.setMinLoadableRetryCount(int). Use SingleSampleMediaSource.Factory.setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy) instead.
      • SsMediaSource.Factory.setMinLoadableRetryCount(int). Use SsMediaSource.Factory.setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy) instead.
    Source code(tar.gz)
    Source code(zip)
  • r2.12.3(Jan 13, 2021)

    • Core library:
      • Fix MediaCodecRenderer issue where empty streams would fail to play in bypass mode (#8374).
      • Fix playback issues after seeking during an ad (#8349).
      • Fix propagation of LoadErrorHandlingPolicy from DefaultMediaSourceFactory into SingleSampleMediaSource.Factory when creating subtitle media sources from MediaItem.playbackProperties.subtitles (#8430).
    • UI:
      • Fix issue where pop-up menus belonging to StyledPlayerControlView would not be dismissed when tapping outside of the menu area or pressing the back button, on API level 22 and earlier (#8272).
    • Downloads:
      • Fix crash in DownloadManager that could occur when adding a stopped download with the same ID as a download currently being removed (#8419).
    • Text:
      • Gracefully handle null-terminated subtitle content in Matroska containers.
      • Fix CEA-708 anchor positioning (#1807).
    • IMA extension:
      • Fix a condition where playback could get stuck before an empty ad (#8205).
      • Log a warning rather than throwing when reaching the end of the stream with an ad playing but without ad media info (#8290).
    • Media2 extension:
      • Make media2-extension depend on AndroidX media2:media2-session:1.1.0 to fix a deadlock while creating PlaybackStateCompat internally (#8011).
    Source code(tar.gz)
    Source code(zip)
  • r2.12.2(Dec 1, 2020)

    • Core library:
      • Suppress exceptions from registering/unregistering the stream volume receiver (#8087, #8106).
      • Suppress ProGuard warnings caused by Guava's compile-only dependencies (#8103).
      • Fix issue that could cause playback to freeze when selecting tracks, if extension audio renderers are being used (#8203).
    • UI:
      • Fix incorrect color and text alignment of the StyledPlayerControlView fast forward and rewind buttons, when used together with the com.google.android.material library (#7898).
      • Add dispatchPrepare(Player) to ControlDispatcher and implement it in DefaultControlDispatcher. Deprecate PlaybackPreparer and setPlaybackPreparer in StyledPlayerView, StyledPlayerControlView, PlayerView, PlayerControlView, PlayerNotificationManager and LeanbackPlayerAdapter and use ControlDispatcher for dispatching prepare instead (#7882).
      • Increase seekbar's touch target height in StyledPlayerControlView.
      • Update StyledPlayerControlView menu items to behave correctly for right-to-left languages.
      • Support enabling the previous and next actions individually in PlayerNotificationManager.
    • Audio:
      • Retry playback after some types of AudioTrack error.
      • Work around AudioManager crashes when calling getStreamVolume (#8191).
    • Extractors:
      • Matroska: Add support for 32-bit floating point PCM, and 8-bit and 16-bit big endian integer PCM (#8142).
      • MP4: Add support for mpeg1 video box (#8257).
    • IMA extension:
      • Upgrade IMA SDK dependency to 3.21.0, and release the AdsLoader (#7344).
      • Improve handling of ad tags with unsupported VPAID ads (#7832).
      • Fix a bug that caused multiple ads in an ad pod to be skipped when one ad in the ad pod was skipped.
      • Fix a bug that caused ad progress not to be updated if the player resumed after buffering during an ad (#8239).
      • Fix passing an ads response to the ImaAdsLoader builder.
      • Set the overlay language based on the device locale by default.
    • Cronet extension:
      • Fix handling of HTTP status code 200 when making unbounded length range requests (#8090).
    • Text
      • Allow tx3g subtitles with styl boxes with start and/or end offsets that lie outside the length of the cue text.
    • Media2 extension:
      • Notify onBufferingEnded when the state of origin player becomes STATE_IDLE or STATE_ENDED.
      • Allow to remove all playlist items that makes the player reset.
    Source code(tar.gz)
    Source code(zip)
  • r2.12.1(Oct 22, 2020)

  • r2.12.0(Sep 21, 2020)

  • r2.11.8(Aug 26, 2020)

Owner
Google
Google ❤️ Open Source
Google
Fermata Media Player is a free, open source audio and video player with a simple and intuitive interface.

Fermata Media Player About Fermata Media Player is a free, open source audio and video player with a simple and intuitive interface. It is focused on

Andrey 227 Jan 6, 2023
ExoPlayer - an application level media player for Android

ExoPlayer is an application level media player for Android. It provides an alternative to Android’s MediaPlayer API for playing audio and video both locally and over the Internet. ExoPlayer supports features not currently supported by Android’s MediaPlayer API, including DASH and SmoothStreaming adaptive playbacks.

Halil Özel 6 Oct 31, 2022
Odeon Music Player is a lightweight music player for Android.

Odeon ?? Odeon Music Player is a lightweight music player for Android. Get it on Google Play. We value your privacy, your battery life and your device

Thibault Seisel 63 Dec 20, 2022
Yet Another Video Player (or YAVP) is a Video Player for Android that is based on Googles ExoPlayer.

Yet Another Video Player Yet Another Video Player (or YAVP) is a Video Player for Android that is based on Googles ExoPlayer. Who Is YAVP For? First o

null 62 Dec 29, 2022
Music Player - This is a basic music player built with Android Studio and Kotlin

Music Player Made by Jenny Cárdenas This is a basic music player built with Android Studio and Kotlin, it shows two views in the UI, the user can play

Jenny C 3 Oct 28, 2021
Compose-video-player - Video player for Android Compose powered by ExoPlayer

Compose Video Player Video player for Android Compose powered by ExoPlayer. Addi

Juan Pablo Herrera 22 Dec 13, 2022
A better Android VideoView with more Media Controller customization. 一个更好用的Android VideoView

Android UniversalVideoView 中文版说明请点击这里 UniversalVideoView is a Android widget helps playing video easier, which is similar with the Android system nati

Linsea 978 Nov 30, 2022
Sandbox project for practice: Media Streaming with Exoplayer (via Android Development tutorial)

Media streaming with ExoPlayer The code in this repository accompanies the Media streaming with ExoPlayer codelab. If you are looking to get started w

Jeannille Hiciano 1 Nov 29, 2021
LNSocial is a social media app dedicated to short-form videos created for and consumed by users.

LNSocial is a social media app dedicated to short-form videos created for and consumed by users. The length of videos is between 15-30 second

null 10 Jan 5, 2023
The Madman library (Media Ads Manager) enables you to advertise video contents with video ads.

Madman (Media ads manager) is a high performance alternative to Google's standard IMA android SDK. If you have your own VAST server and want to render video ads and have full control over the UI, then this library is for you.

Flipkart Incubator 65 Nov 10, 2022
mpv-android is a video player for Android based on libmpv.

mpv-android is a video player for Android based on libmpv.

null 1.1k Jan 6, 2023
Echo is a lightweight and minimal music player for Android, built with Android Studio and written in Kotlin

Echo - Echo, A light-weight, minimal music player for Android, with shuffle, favorites and audio visualization

Divins Mathew 0 Feb 7, 2022
Android/iOS video player based on FFmpeg n3.4, with MediaCodec, VideoToolbox support.

ijkplayer Platform Build Status Android iOS Video player based on ffplay Download Android: Gradle # required allprojects { repositories {

bilibili 31k Jan 3, 2023
Custom Android view with video player, loader and placeholder image

VideoPlayerView Custom Android view with video player, loader and placeholder image. To stay up-to-date with news about the library Usage Here is an e

Marcin Moskała 89 Nov 18, 2022
Android music player example.

Android music player example.

Chien 21 Jul 29, 2022
A elegant and light weight music player for android

A elegant and light weight music player for android

Atul Patare 45 Dec 21, 2022
NOVA is an open source video player for Android

NOVA: opeN sOurce Video plAyer Overview NOVA is an open source video player for Android. It consists in a fork of the original Archos Video Player Com

NOVA 876 Jan 2, 2023
Simple and lightweight, yet polished and powerful Android video player based on ExoPlayer

Just (Video) Player Android video player based on ExoPlayer It uses ExoPlayer's extension-ffmpeg with all its audio formats enabled (it can handle eve

Marcel Dopita 677 Dec 28, 2022
Best material design music player for Android

Metro Material Design music player for Android music lovers Table of contents Downloads Differences between Metro and RetroMusicPlayer Screenshots App

Muntashir Al-Islam 684 Jan 1, 2023