Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update and fixed BUG java.lang.NullPointerException: MediaSource.Factory#setDrmSessionManagerProvider #1085

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tintran-dev
Copy link

@tintran-dev tintran-dev commented Sep 23, 2022

  • Update exoplayer version to 2.18.1
  • Update gradle version 7.3.0 support jdk 11 and kotlin 1.6.+
  • Update kotlin version to 1.7.10
  • Fixed error java.lang.NullPointerException: MediaSource.Factory#setDrmSessionManagerProvider
  • Upgrade compilesdkversion to 33 support for android 12+ run on gradle 7.3.0
  • To use:

better_player:

git:

url: https://github.com/tintran-dev/betterplayer.git

…sion to 7.3.0, kotlin version to 1.7.10, exoPlayerVersion to "2.18.1"
@GabrielRStabile
Copy link

Your fix is working here, thank u

@ronbadur
Copy link

ronbadur commented Oct 1, 2022

works like a charm, thanks!
we need to merge that into master

@Nabute
Copy link

Nabute commented Oct 2, 2022

I just came around to this bug and used the git version of the package and when I try to play the video it throws this error. It was working fine before I updated it.

Caused by: com.google.android.exoplayer2.source.UnrecognizedInputFormatException: None of the available extractors (FlvExtractor, FlacExtractor, WavExtractor, FragmentedMp4Extractor, Mp4Extractor, AmrExtractor, PsExtractor, OggExtractor, TsExtractor, MatroskaExtractor, AdtsExtractor, Ac3Extractor, Ac4Extractor, Mp3Extractor, AviExtractor, JpegExtractor) could read the stream.

image

@Nabute
Copy link

Nabute commented Oct 3, 2022

I have resolved it.

For future users:

If you face such issue, please provide videoFormat: BetterPlayerVideoFormat.hls, since in my case the video URL was
https://streaming_server/path/to/video_,24,36,48,72,108,0p.mp4.urlset/master.m3u8

@tintran-dev
Copy link
Author

I have resolved it.

For future users:

If you face such issue, please provide videoFormat: BetterPlayerVideoFormat.hls, since in my case the video URL was https://streaming_server/path/to/video_,24,36,48,72,108,0p.mp4.urlset/master.m3u8

Yes! We should set the input video format for the player to be able to recognize what standard the video belongs to.
EX:
.m3u8 is videoFormat: BetterPlayerVideoFormat.hls
.mpd is videoFormat: BetterPlayerVideoFormat.dash
other set null

@SamerCat
Copy link

SamerCat commented Nov 4, 2022

Is there any solution other than upgrade the gradle, because I can't for now upgrade it

@tintran-dev
Copy link
Author

tintran-dev commented Nov 7, 2022

@SamerCat
You can clone source: https://github.com/tintran-dev/betterplayer.git to use local package in this your PC and then you can android studio to open folder android in package, edit gradle version back to 7.0.2 in file android/build.gradle: ext.gradleVersion = "7.0.2"

@JoseBarreto1
Copy link

Your fix is working here, thank u

@Tha14
Copy link

Tha14 commented Nov 16, 2022

@jhomlala This pr fixes #1116 and #1113. Please merge.

@moazelsawaf
Copy link

moazelsawaf commented Dec 28, 2022

Great, thank you so much 🙏🏻❤

@jhomlala
Kindly review and merge this one ... 🙏🏻

@yfming93
Copy link

yfming93 commented Jan 7, 2023

  • Update exoplayer version to 2.18.1
  • Update gradle version 7.3.0 support jdk 11 and kotlin 1.6.+
  • Update kotlin version to 1.7.10
  • Fixed error java.lang.NullPointerException: MediaSource.Factory#setDrmSessionManagerProvider
  • Upgrade compilesdkversion to 33 support for android 12+ run on gradle 7.3.0
  • To use:

better_player:

git:

url: https://github.com/tintran-dev/betterplayer.git

thanks! It is work ok for me.

Comment on lines 385 to 395
if (lastPathSegment == null) {
lastPathSegment = ""
}
type = Util.inferContentType(lastPathSegment)
type = Util.inferContentTypeForExtension(lastPathSegment)
} else {
type = when (formatHint) {
FORMAT_SS -> C.TYPE_SS
FORMAT_DASH -> C.TYPE_DASH
FORMAT_HLS -> C.TYPE_HLS
FORMAT_OTHER -> C.TYPE_OTHER
FORMAT_SS -> C.CONTENT_TYPE_SS
FORMAT_DASH -> C.CONTENT_TYPE_DASH
FORMAT_HLS -> C.CONTENT_TYPE_HLS
FORMAT_OTHER -> C.CONTENT_TYPE_OTHER
else -> -1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be changed to:

        val type: Int = if (formatHint == null) {
            Util.inferContentType(uri)
        } else {
            when (formatHint) {
                FORMAT_SS -> C.CONTENT_TYPE_SS
                FORMAT_DASH -> C.CONTENT_TYPE_DASH
                FORMAT_HLS -> C.CONTENT_TYPE_HLS
                FORMAT_OTHER -> C.CONTENT_TYPE_OTHER
                else -> -1
            }
        }

Because Util.inferContentTypeForExtension(lastPathSegment) works incorrectly for the segment, it should be the extension of file/uri (e.g. mpd or m3u8). Please, fix the PR.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, it is for ExoPlayer 2.18.1 (Android) and above.

@greyovo
Copy link

greyovo commented Feb 9, 2023

For future users: if this didnt work for u, stop your current debug process and restart from scratch:

  • run flutter clean
  • then run flutter run

@priyank-dt
Copy link

  • Update exoplayer version to 2.18.1
  • Update gradle version 7.3.0 support jdk 11 and kotlin 1.6.+
  • Update kotlin version to 1.7.10
  • Fixed error java.lang.NullPointerException: MediaSource.Factory#setDrmSessionManagerProvider
  • Upgrade compilesdkversion to 33 support for android 12+ run on gradle 7.3.0
  • To use:

better_player:

git:

url: https://github.com/tintran-dev/betterplayer.git

@tintran-dev getting below error while playing .m3u8 video link on Android devices (like, Android 11, 12 & 13)
(URL => https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8)

Playback error
com.google.android.exoplayer2.ExoPlaybackException: Source error
Caused by: com.google.android.exoplayer2.source.UnrecognizedInputFormatException: None of the available extractors (FlvExtractor, FlacExtractor, WavExtractor, FragmentedMp4Extractor, Mp4Extractor, AmrExtractor, PsExtractor, OggExtractor, TsExtractor, MatroskaExtractor, AdtsExtractor, Ac3Extractor, Ac4Extractor, Mp3Extractor, AviExtractor, JpegExtractor) could read the stream.
Unhandled Exception: PlatformException(VideoError, Video player had error com.google.android.exoplayer2.ExoPlaybackException: Source error, , null)

@tintran-dev help us to solve this.

@FlatCodeIq
Copy link

For your information, this issue is still on-going. The fix by @tintran-dev worked. But this must be fixed by @jhomlala at some point please !?

@Faiyyaz
Copy link

Faiyyaz commented Jul 31, 2023

@tintran-dev it is not picking proper hls track for audio after update

@guyluz11
Copy link

I have merged this alongside more updates to this fork which you can use for now

  better_player:
    git:
      url: 'https://github.com/guyluz11/betterplayer.git'
      ref: 'merge_fixes'

@developerAkX
Copy link

@guyluz11 Thank you sir you saved me 🫡

@fabioselau077
Copy link

Is there any reason why this hasn't been merged yet?

@Tha14
Copy link

Tha14 commented Nov 26, 2023

Is there any reason why this hasn't been merged yet?

Because the repo owner is not responding anymore. I have been using titran's fork ever since without issues.

@ShejaEddy
Copy link

Hey @tintran-dev thanks for your fixes, I'm having issues integrating your changes with my project having flutter 2.1.13, is there a way to implement your changes without having to change my flutter version to 3.1.0 please?

I can not upgrade flutter because many packages depend on flutter 2.1.13. Thanks in advance.

@topex-psy
Copy link

Good forks are everywhere. If the plugin owner doesn't respond anymore, I suggest publishing it as a new pub.dev package using a new name e.g. best_player.

@pavanlashkari
Copy link

  • Update exoplayer version to 2.18.1
  • Update gradle version 7.3.0 support jdk 11 and kotlin 1.6.+
  • Update kotlin version to 1.7.10
  • Fixed error java.lang.NullPointerException: MediaSource.Factory#setDrmSessionManagerProvider
  • Upgrade compilesdkversion to 33 support for android 12+ run on gradle 7.3.0
  • To use:

better_player:

git:

url: https://github.com/tintran-dev/betterplayer.git

thank you solve the issue and save my time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet