MrJai / flutter_to_airplay

Flutter plugin that offers two widgets, one to play a video for a given URL or file path using native AVPlayer and second with an option to airplay it on available Apple devices.
MIT License
30 stars 24 forks source link

Instant crash in iOS simulator iPhone 12 - please help #16

Closed daveshirman closed 3 years ago

daveshirman commented 3 years ago

First of all thanks for this!

So I'm just trying to either:

1) Use better_player - as I was already doing - then show the airplay cast widget.

OR

2) Use your native player widget in place of better_player - which has the airplay icon built-in.

e.g.

  Widget _buildvideoPlayer(Video video) {
    if (Platform.isIOS) {
      return FlutterAVPlayerView(
        urlString: widget.video.videoM3u8,
      );
    }

    // Otherwise on Android - load different player.

    return AspectRatio(
      aspectRatio: 16 / 9,
      child: BetterPlayer(
        controller: _betterVideoController!,
      ),
    );
  }
}

Both instantly crash the simulator.

Can you provide at least a minimum code example in-context of how to use your two widgets please?

Thank you.

MrJai commented 3 years ago

@daveshirman Thank you for reporting this. I had a very busy week so couldn't check this.

Let me try your code snippet and get back to you.

daveshirman commented 3 years ago

No problem at all. I am happy to donate to your funding if it helps you spend some time improving the docs/bugs as this is an excellent feature if working. Thank you.

On Mon, 26 Jul 2021, 01:38 Junaid Rehmat, @.***> wrote:

@daveshirman https://github.com/daveshirman Thank you for reporting this. I had a very busy week so couldn't check this.

Let me try your code snippet and get back to you.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/MrJai/flutter_to_airplay/issues/16#issuecomment-886391804, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADM6KXS6ZO7KTBSWBDHAIM3TZTYD3ANCNFSM5ATX4UFA .

MrJai commented 3 years ago

@daveshirman I am working on this issue today. But I am unable to reproduce the crash you mentioned. Can you please share some code snippets that will cause the crash?

Also, I noticed that you are asking, for example, I have added the example in the project, and one case is added by default where the video is being loaded from a URL, whereas the other case is commented out where a video can be loaded from assets.

https://github.com/MrJai/flutter_to_airplay/blob/46904f383ff464e04b21f1ddd255129ce3822a95/example/lib/main.dart

Please let me know if you want me to cover more cases in the example project. Please feel free to share if you want some more features in this plugin as well.

daveshirman commented 3 years ago

Thank you so much for your reply. I really didn't do anything but set it up as per your original example, perhaps I missed something, like an important step in the setup on iOS Xcode project?

I will try to run the plugin again today and reply to you here.

Thank you and please tell me where I can donate to keep you funded! Put a button on your GitHub if you haven't already. You deserve it.

On Thu, 5 Aug 2021, 07:55 Junaid Rehmat, @.***> wrote:

@daveshirman https://github.com/daveshirman I am working on this issue today. But I am unable to reproduce the crash you mentioned. Can you please share some code snippets that will cause the crash?

Also, I noticed that you are asking, for example, I have added the example in the project, and one case is added by default where the video is being loaded from a URL, whereas the other case is commented out where a video can be loaded from assets.

https://github.com/MrJai/flutter_to_airplay/blob/46904f383ff464e04b21f1ddd255129ce3822a95/example/lib/main.dart

Please let me know if you want me to cover more cases in the example project. Please feel free to share if you want some more features in this plugin as well.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/MrJai/flutter_to_airplay/issues/16#issuecomment-893398453, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADM6KXVQ2VJP65OHKRTQFM3T3J33TANCNFSM5ATX4UFA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

MrJai commented 3 years ago

Thank you @daveshirman, I have just added some more examples on the basis of the frequently asked uses cases.

For donations, you can buy me as many coffees as you want, because being a developer I convert caffeine to code :P

Buy Me A Coffee

daveshirman commented 3 years ago

UPDATE:

I am no longer seeing this instant crash if I just use the AirPlayRoutePickerView

BUT If I use the FlutterAVPlayerView, my app crashses on my iPhone 6s on iOS 14 as soon as the page attempts to load with this:

  Widget _buildVideoSection(Video video) {
    return Padding(
      padding: const EdgeInsets.all(16.0),
      child: ClipRRect(
        borderRadius: BorderRadius.circular(8),
        child: FlutterAVPlayerView(
          urlString: widget.video.videoM3u8, // this is an https fully qualified url.
        ),
      ),
    );
  }

Error:

*** Assertion failure in -[NSLayoutConstraint _setSymbolicConstant:constant:symbolicConstantMultiplier:], NSLayoutConstraint.m:670
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSLayoutConstraint constant is not finite!  That's illegal.  constant:inf firstAnchor:<NSLayoutDimension:0x2820e4240 "AVPlaybackControlsView:0x11810b200.height"> secondAnchor:(null)'

Question I guess (having not used this before), is can I use that to mirror the app in general, whilst using my own video player, or do I have to use that widget in conjunction with the FlutterAVPlayerView in order to mirror video content within my app?

Thank you so much, donation coming your way as soon as I've got this release build done!

MrJai commented 3 years ago

yes you can use it with any player.

daveshirman commented 3 years ago

Thanks, so I'm using just the AirPlayRoutePickerView and I can successfully cast the video out, great.

Also - did you see my error I pasted above?

Looks like a simple layout problem is my guess.

I noticed the crash happens with the AirPlayRoutePickerView widget too if it's not in a container with a width and height defined. Hope that helps.

MrJai commented 3 years ago

Yes, that is intentional behaviour, because I am just providing a control, users can customise its appearance as per their app's UI. I will document it in the next version.

MrJai commented 3 years ago

Thank you @daveshirman for coffees.

I think we can close this issue now? You can always open new issue, or reach out to me via twitter at @Rana_Jai.

daveshirman commented 3 years ago

You're welcome. I think as long as the documentation explains that if you don't supply a wrapping widget with dimensions, it will crash, then yeah. Cheers.

On Fri, 6 Aug 2021, 21:05 Junaid Rehmat, @.***> wrote:

Closed #16 https://github.com/MrJai/flutter_to_airplay/issues/16.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/MrJai/flutter_to_airplay/issues/16#event-5125242439, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADM6KXUQKBJHBL7AEKJFZGTT3SBGVANCNFSM5ATX4UFA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

MrJai commented 3 years ago

Hi @daveshirman, I just updated the package and its changelog as well. Now the widget comes wrapped around in a 44 x 44 container, but its width and height are customizable, and users can change it as per their need/design requirements. It is also documented both in Changelog and in widget documentation.