Wayaer / fl_pip

flutter picture-in-picture plugin for ios and android
MIT License
28 stars 14 forks source link

Unable to Test on Simulator: 'PiP Unavailable' Error" #3

Closed huantd0111 closed 1 year ago

huantd0111 commented 1 year ago

I'm trying to test the fl_pip package on the iOS Simulator, but I'm encountering an error that says "PiP unavailable." I've followed the instructions in the iOS configuration section, where I added Background Modes and checked Audio, AirPlay, and Picture in Picture capabilities.

Steps to Reproduce:

  1. Clone the repository.
  2. Follow the iOS configuration steps (Signing & Capabilities -> Capability, add Background Modes, check Audio, AirPlay, and Picture in Picture).
  3. Run the app on the iOS Simulator.
  4. Observe the "PiP unavailable" error.

Expected Behavior:

I expect to be able to test the fl_pip package successfully on the iOS Simulator without encountering the "PiP unavailable" error.

Additional Notes:

Additionally, I'd appreciate more clarification on the toggle method. The documentation for this method seems unclear, and I'm having trouble understanding how to implement it on both Android and iOS. I'm interested in implementing an automatic PiP mode when the app is swiped into the background on iOS, similar to the behavior seen in the YouTube app. Is there a way to achieve this using the fl_pip package?

I tried referring to the discussion in this GitHub issue, but I'm facing difficulties when attempting to test this directly on the iOS Simulator. The issue arises even before I can properly test the solution mentioned.

Questions:

  1. Is there an example or guide available that demonstrates how to automatically activate PiP mode when the app is swiped into the background?
  2. Is the automatic activation of PiP mode supported on iOS Simulator?
  3. Are there any specific configurations or additional steps needed to make this work on iOS Simulator?
  4. Could you provide more context or clarification on how the toggle mechanism works in this context, especially when dealing with iOS?

Thank you for your assistance!

Wayaer commented 1 year ago

The ios emulator cannot support the picture-in-picture mode, and must use the real machine, Switch background and look at this

huantd0111 commented 1 year ago

Additionally, I'd appreciate more clarification on the toggle method. The documentation for this method seems unclear, and I'm having trouble understanding how to implement it on both Android and iOS.

Thankiu @Wayaer Additionally, I'd appreciate more clarification on the toggle method. The documentation for this method seems unclear, and I'm having trouble understanding how to implement it on both Android and iOS.

Wayaer commented 1 year ago

On android, the toggle method can make the app enter the background or foreground by calling the code, but on ios, it can only be switched to the background. After this, it has nothing to do with the picture-in-picture mode

Wayaer commented 1 year ago

Here's this code in example, when you go into picture-in-picture mode, the app goes into the background

huantd0111 commented 1 year ago

Here's this code in example, when you go into picture-in-picture mode, the app goes into the background

Previously, I had read through the example and implemented this library on Android. However, I didn't call "FlPiP().toggle(AppState.background);" and yet the PIP mode was still activated. I will try the example again and gain a clearer understanding of the "toggle" method's functionality. Thanks once again for your swift response and assistance.

huantd0111 commented 1 year ago

Here's this code in example, when you go into picture-in-picture mode, the app goes into the background

Previously, I had read through the example and implemented this library on Android. However, I didn't call "FlPiP().toggle(AppState.background);" and yet the PIP mode was still activated. I will try the example again and gain a clearer understanding of the "toggle" method's functionality. Thanks once again for your swift response and assistance.

Hi @Wayaer I retested the sample application and observed that when I call "FlPiP().toggle(AppState.background);," the app indeed goes into the background. Additionally, I commented out the content of the listener method, and the PIP functionality still works as expected. So, my question is: what is the purpose of your check:

if (FlPiP().status.value == PiPStatus.enabled) {
  FlPiP().toggle(AppState.background);
}

Does it serve a specific purpose, perhaps for the iOS platform? Because from what I observed, this listener and action seem redundant on Android.

Thank you for your prompt responses and guidance.

Wayaer commented 1 year ago

On android, the app will automatically enter the background when you enable the picture-in-picture mode, but when you use the enableWithEngine method, it will not automatically enter the background, and on ios, whether you call either of the two will not automatically enter the background.

Wayaer commented 1 year ago

enableWithEngine and enable both use the picture-in-picture function in ios, but the windows manager used by the former in android is not a native picture-in-picture mode

huantd0111 commented 1 year ago

@Wayaer Thank you for your assistance, I have resolved the issue. However, I would appreciate it if you could update the information we discussed in the library's document. This could be helpful for newcomers who access the library.