siddhesh-tamhanekar / media_player

An flutter media player to make media streaming apps effortlessly! read getting started tutorial on https://medium.com/@tamhanekar.siddhesh95/integrate-media-player-into-your-flutter-application-23040213f0c9
MIT License
46 stars 22 forks source link

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.endsWith(java.lang.String)' on a null object reference #6

Closed karnadii closed 5 years ago

karnadii commented 5 years ago

i got this error when setting a playlist,

I/MediaPlayerPlugin(15056): neeeded background exoplayer
I/audio service binder(15056): starting player in bakground
I/VideoPlayer.java(15056): VideoPlayer constuctor
I/ExoPlayerImpl(15056): Init 9df314f [ExoPlayerLib/2.9.1] [kenzo, Redmi Note 3, Xiaomi, 23]
I/flutter (15056): [{type: audio, source: http://103.226.246.18:80/masima-pramborsjakarta, title: Prambors FM / Jakarta, desc: null}, {type: audio, source: http://streaming.sim-indonesia.com:8000/genfm, title: Gen FM, desc: null}, {type: audio, source: http://mahaka.rastream.com:80/jak.bb, title: Jak fm, desc: null}, {type: audio, source: http://202.147.199.99:8000/, title: Radio Dangdut Indonesia, desc: null}, {type: audio, source: http://listento.ardanradio.com:1059/, title: Ardan FM, desc: null}, {type: audio, source: http://bogor.nagaswarafm.com:8088/, title: Nagaswara FM, desc: null}, {type: audio, source: http://cloudstreaming.mramedia.com:8001/live, title: Hard Rock FM / Jakarta, desc: null}, {type: audio, source: http://202.137.4.147:8000/;, title: Radio Elshinta, desc: null}, {type: audio, source: http://masima.rastream.com/masima-deltasurabaya, title: Delta FM 968, desc: null}, {type: audio, source: http://live2.radiorodja.com, title: Radio Rodja, desc: null}, {type: audio, source: http://cloudstreaming.mramedia.com:
D/MediaPlayerPlugin(15056): Playlist=[{type=audio, desc=null, title=Prambors FM / Jakarta, source=http://103.226.246.18:80/masima-pramborsjakarta}, {type=audio, desc=null, title=Gen FM, source=http://streaming.sim-indonesia.com:8000/genfm}, {type=audio, desc=null, title=Jak fm, source=http://mahaka.rastream.com:80/jak.bb}, {type=audio, desc=null, title=Radio Dangdut Indonesia, source=http://202.147.199.99:8000/}, {type=audio, desc=null, title=Ardan FM, source=http://listento.ardanradio.com:1059/}, {type=audio, desc=null, title=Nagaswara FM, source=http://bogor.nagaswarafm.com:8088/}, {type=audio, desc=null, title=Hard Rock FM / Jakarta, source=http://cloudstreaming.mramedia.com:8001/live}, {type=audio, desc=null, title=Radio Elshinta, source=http://202.137.4.147:8000/;}, {type=audio, desc=null, title=Delta FM 968, source=http://masima.rastream.com/masima-deltasurabaya}, {type=audio, desc=null, title=Radio Rodja, source=http://live2.radiorodja.com}, {type=audio, desc=null, title=I Radio FM, source=http://cloudstreaming.mramedia.com:8000/live}, {type=audio, desc=null, title=Mustang 88 FM Jakarta, source=http://streaming2.sim-indonesia.com:8000/mustang}, {type=audio, desc=null, title=Dengerin Musik, source=http://198.56.183.99:8000/stream}, {type=audio, desc=null, title=OZ Radio Bandung, source=http://45.64.97.211:1031/}, {type=audio, desc=null, title=Gen FM Surabaya, source=http://streaming.sim-indonesia.com:8000/gensby}, {type=audio, desc=null, title=Suara Muslim, source=http://radio.useetv.com:8024}, {type=audio, desc=null, title=Trax FM Jakarta, source=http://cloudstreaming.mramedia.com:8003/live}, {type=audio, desc=null, title=Kis 95.1 FM, source=http://streaming2.sportku.com:8000/kis}, {type=audio, desc=null, title=Radio Syiar Tauhid, source=http://live.syiartauhid.info:8046/;}, {type=audio, desc=null, title=Suara Surabaya Radio, source=http://s9.viastreaming.net:7020/}, {type=audio, desc=null, title=Angling Darma FM, source=http://s4.vinhostmedia.com:8000/adfm}, {type=audio, desc=null, title=Rama FM Bandung, source=http://rama-fm.simaya.net.id:8800}, {type=audio, desc=null, title=FeMale Radio, source=http://stream.masima.co.id:8894}, {type=audio, desc=null, title=Radio Pelita Kasih 96.3 FM, source=http://rpkfm.indostreamserver.com:8030}, {type=audio, desc=null, title=Sonora FM, source=http://103.226.246.245/kompas-sonorajakarta}, {type=audio, desc=null, title=Urban Radio Bandung, source=http://radio.melsa.net.id:8050/urban}, {type=audio, desc=null, title=Mazmur FM, source=http://u.klikhost.com:7118}, {type=audio, desc=null, title=Menara 102.8 FM Denpasar, source=http://server.menara-fm.com:10280/menarafmbali}, {type=audio, desc=null, title=Radio waton muni, source=http://45.64.97.211:7511/}, {type=audio, desc=null, title=Radio Dahlia, source=http://dahlia-fm.simaya.net.id:1060}]
E/MethodChannel#com.example.media_player(15056): Failed to handle method call
E/MethodChannel#com.example.media_player(15056): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.endsWith(java.lang.String)' on a null object reference
E/MethodChannel#com.example.media_player(15056):    at com.google.android.exoplayer2.util.Util.inferContentType(Util.java:1406)
E/MethodChannel#com.example.media_player(15056):    at com.example.mediaplayer.VideoPlayer.buildMediaSource(VideoPlayer.java:143)
E/MethodChannel#com.example.media_player(15056):    at com.example.mediaplayer.VideoPlayer.setPlaylist(VideoPlayer.java:134)
E/MethodChannel#com.example.media_player(15056):    at com.example.mediaplayer.MediaPlayerPlugin.onMethodCall(MediaPlayerPlugin.java:189)
E/MethodChannel#com.example.media_player(15056):    at com.example.mediaplayer.MediaPlayerPlugin.onMethodCall(MediaPlayerPlugin.java:170)
E/MethodChannel#com.example.media_player(15056):    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:212)
E/MethodChannel#com.example.media_player(15056):    at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:88)
E/MethodChannel#com.example.media_player(15056):    at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:234)
E/MethodChannel#com.example.media_player(15056):    at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#com.example.media_player(15056):    at android.os.MessageQueue.next(MessageQueue.java:323)
E/MethodChannel#com.example.media_player(15056):    at android.os.Looper.loop(Looper.java:141)
E/MethodChannel#com.example.media_player(15056):    at android.app.ActivityThread.main(ActivityThread.java:5603)
E/MethodChannel#com.example.media_player(15056):    at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#com.example.media_player(15056):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774)
E/MethodChannel#com.example.media_player(15056):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)
E/flutter (15056): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'boolean java.lang.String.endsWith(java.lang.String)' on a null object reference, null)
E/flutter (15056): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
E/flutter (15056): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:302:33)
E/flutter (15056): <asynchronous suspension>
E/flutter (15056): #2      MediaPlayer.setPlaylist (package:media_player/media_player.dart:154:20)
E/flutter (15056): <asynchronous suspension>
E/flutter (15056): #3      BerandaBloc.getRadioList.<anonymous closure> (package:radiosuka/blocs/beranda.dart:80:19)
E/flutter (15056): #4      _rootRunUnary (dart:async/zone.dart:1132:38)
E/flutter (15056): #5      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter (15056): #6      _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
E/flutter (15056): #7      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45)
E/flutter (15056): #8      Future._propagateToListeners (dart:async/future_impl.dart:668:32)
E/flutter (15056): #9      Future._complete (dart:async/future_impl.dart:473:7)
E/flutter (15056): #10     _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
E/flutter (15056): #11     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:28:18)
E/flutter (15056): #12     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:294:13)
E/flutter (15056): #13     DatabaseHelper.getRadioList (package:radiosuka/utill/database_helper.dart)
E/flutter (15056): <asynchronous suspension>
E/flutter (15056): #14     BerandaBloc.getRadioList (package:radiosuka/blocs/beranda.dart:68:51)
E/flutter (15056): <asynchronous suspension>
E/flutter (15056): #15     BerandaBloc.firstStart (package:radiosuka/blocs/beranda.dart:125:13)
E/flutter (15056): <asynchronous suspension>
E/flutter (15056): #16     BerandaBloc.init (package:radiosuka/blocs/beranda.dart:32:5)
E/flutter (15056): <asynchronous suspension>
E/flutter (15056): #17     _BerandaPageState.initState (package:radiosuka/views/beranda.dart:16:8)
E/flutter (15056): #18     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3934:58)
E/flutter (15056): #19     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3805:5)
E/flutter (15056): #20     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3044:14)
E/flutter (15056): #21     Element.updateChild (package:flutter/src/widgets/framework.dart:2847:12)
E/flutter (15056): #22     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4964:14)
E/flutter (15056): #23     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3044:14)
E/flutter (15056): #24     Element.updateChild (package:flutter/src/widgets/framework.dart:2847:12)
E/flutter (15056): #25     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3838:16)
E/flutter (15056): #26     Element.rebuild (package:flutter/src/widgets/framework.dart:3648:5)
E/flutter (15056): #27     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3810:5)
E/flutter (15056): #28     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3805:5)
E/flutter (15056): #29     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3044:14)
E/flutter (15056): #30     Element.updateChild (package:flutter/src/widgets/framework.dart:2847:12)
E/flutter (15056): #31     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4964:14)
E/flutter (15056): #32     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3044:14)
E/flutter (15056): #33     Element.updateChild (package:flutter/src/widgets/framework.dart:2847:12)
E/flutter (15056): #34     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4964:14)
E/flutter (15056): #35     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3044:14)
E/flutter (15056): #36     Element.updateChild (package:flutter/src/widgets/framework.dart:2847:12)
E/flutter (15056): #37     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4964:14)
E/flutter (15056): #38     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3044:14)
E/flutter (15056): #39     Element.updateChild (package:flutter/src/widgets/framework.dart:2847:12)
E/flutter (15056): #40     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4964:14)
E/flutter (15056): #41     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3044:14)
E/flutter (15056): #42     Element.updateChild (package:flutter/src/widgets/framework.dart:2847:12)
E/flutter (15056): #43     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3838:16)
E/flutter (15056): #44     Element.rebuild (package:flutter/src/widgets/fram

my code

Future<List<Radios>> radioListFuture = helper.getRadioList(offset);
    radioListFuture.then((radioList) {
      this.radioListDB = radioList;
      for (Radios radio in radioList) {
        this.playlist.add(MediaFile(
            title: radio.title, source: radio.streamUrl, type: "audio"));
      }
      this.player.setPlaylist(Playlist(this.playlist));
    });
siddhesh-tamhanekar commented 5 years ago

Some of the sources in Playlist may be causing this issue The exoplayer throws an error when there is an issue in determining contentType of some source.

Please Try to play every source in the playlist individually and try to catch the source which causing this issue.

I have tried some of the random sources from your playlist and they work fine for me.

karnadii commented 5 years ago

@siddhesh-tamhanekar some of my source returning 404 and 503, is it can cause this error?

karnadii commented 5 years ago

can i override the next and prev event in notification controller? or maybe remove the next/prev? seems the only solution for me is to setSource

playRadio(int index) async {
       player.setSource(MediaFile(
        title: radioListDB[index].title,
        source: radioListDB[index].streamUrl,
        type: "audio"));
    player.play();
  }

but if I using this code the next prev just playing the same source,

siddhesh-tamhanekar commented 5 years ago

You could eliminate buggy sources and try to give it as a playlist.

siddhesh-tamhanekar commented 5 years ago

Closing this issue due to inactivity