flutter_playout icon indicating copy to clipboard operation
flutter_playout copied to clipboard

No notification in iOS 13.3

Open artths opened this issue 5 years ago • 8 comments

When I play the video on iPhone 8 simulator with iOS 13.3 I get no notifications. Am I doing something wrong or it's a bug?

 _videoPlayer = Video(
              autoPlay: true,
              url: link,
              title: 'Title',
              subtitle: 'Subtitle',
            );

artths avatar Jan 17 '20 17:01 artths

Try adding this to Video(),

onViewCreated: (viewId) {
    listenForVideoPlayerEvents(viewId);
},

KhuramKhalid avatar Jan 17 '20 17:01 KhuramKhalid

How can I add this while using just Video class without implementing PlayerObserver?

artths avatar Jan 17 '20 18:01 artths

Please see lib/player_observer.dart. It's just an EventChannel based on the created viewId.

EventChannel eventChannel = EventChannel(
        "tv.mta/NativeVideoPlayerEventChannel_$viewId", JSONMethodCodec());
    eventChannel.receiveBroadcastStream().listen(_processEvent);

Then see implementation of _processEvent(dynamic event) for various events.

KhuramKhalid avatar Jan 17 '20 18:01 KhuramKhalid

It would be great if EventChannel was setup during widget creation inside the Video class, so we can create Video instance anywhere while having notifications out of the box. Then we can have optional onPlayerEvents param if we want to listen for the player events. Something like this:

 _videoPlayer = Video(
              autoPlay: true,
              url: link,
              title: 'Title',
              subtitle: 'Subtitle',
              onPlayerEvents: (event) {
                   if(event == Event.PAUSED) ...
              } );

Sorry to bother you so much. If you agree with my ideas I could try creating PRs.

artths avatar Jan 17 '20 18:01 artths

Right so with this there would be a few things to iron out. Firstly, I think this would make the client code more unreadable since onPlayerEvents would be responsible for handling all events so you'll end up with a lot of if statements. Secondly, a few events also return data for example onTime returns the current play head position. So then this method would also need to provide a way for that; making code more unreadable. Lastly, I wanted to keep observer as a pluggable component because soon I want to implement client side player analytics integrating with Brightcove and Google Analytics. So then those analytics would extend PlayerObserver and in client implementation instead of mixing PlayerObserver, we'll mix something like PlayerObserverWithGoogleAnalytics.

KhuramKhalid avatar Jan 18 '20 10:01 KhuramKhalid

Okay. I just don't like we need to implement PlayerObserver in order to get notifications, it should be not connected together. Moreover, I just tried to implement PlayerObserver and got no notifications. Also requirement to call listenForVideoPlayerEvents makes the plugin API not so clean looking. What if we make optional param playerObserver like this:

 _videoPlayer = Video(
              autoPlay: true,
              url: link,
              title: 'Title',
              subtitle: 'Subtitle',
              playerObserver: PlayerObserverWithGoogleAnalytics(),
              );

While calling listenForVideoPlayerEvents automatically whenever or not playerObserver specified?

artths avatar Jan 18 '20 14:01 artths

I use example project run on iOS but not show notification, test on iOS 12 and iOS 13 help me pls

minhdev2017 avatar Mar 09 '20 08:03 minhdev2017

Same, just tried latest version and still no notifications. I call listenForVideoPlayerEvents(viewId);, where can be error?

artths avatar Apr 11 '20 13:04 artths