Skip to content

Commit bb9c5b3

Browse files
decisivearmorclaude
andcommitted
feat: Add iOS PiP support configuration and debug logging
- Add UIBackgroundModes audio capability to Info.plist for PiP support - Add comprehensive debug logging to setPictureInPictureEnabled method - Add detailed error logging for PiP failures This enables Picture-in-Picture functionality on iOS devices and provides better debugging information when PiP fails to start. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 25788ba commit bb9c5b3

File tree

2 files changed

+23
-0
lines changed
  • packages/video_player
    • video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation
    • video_player/example/ios/Runner

2 files changed

+23
-0
lines changed

packages/video_player/video_player/example/ios/Runner/Info.plist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,9 @@
5050
<true/>
5151
<key>UIApplicationSupportsIndirectInputEvents</key>
5252
<true/>
53+
<key>UIBackgroundModes</key>
54+
<array>
55+
<string>audio</string>
56+
</array>
5357
</dict>
5458
</plist>

packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPVideoPlayer.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,26 +531,42 @@ - (void)removeKeyValueObservers {
531531
- (void)setPictureInPictureEnabled:(BOOL)enabled {
532532
#if TARGET_OS_IOS
533533
if (@available(iOS 9.0, *)) {
534+
NSLog(@"setPictureInPictureEnabled called with enabled: %@", enabled ? @"YES" : @"NO");
535+
NSLog(@"Current playerLayer: %@", _playerLayer);
536+
NSLog(@"Current pipController: %@", _pipController);
537+
NSLog(@"isPictureInPictureSupported: %@", [AVPictureInPictureController isPictureInPictureSupported] ? @"YES" : @"NO");
538+
534539
if (enabled && !_pipController) {
535540
// Create AVPlayerLayer if not exists
536541
if (!_playerLayer) {
542+
NSLog(@"Creating new AVPlayerLayer");
537543
_playerLayer = [AVPlayerLayer playerLayerWithPlayer:_player];
538544
}
539545

540546
// Create PiP controller
541547
if ([AVPictureInPictureController isPictureInPictureSupported]) {
548+
NSLog(@"Creating AVPictureInPictureController with playerLayer: %@", _playerLayer);
542549
_pipController = [[AVPictureInPictureController alloc] initWithPlayerLayer:_playerLayer];
543550
_pipController.delegate = self;
551+
NSLog(@"PiP controller created: %@", _pipController);
552+
} else {
553+
NSLog(@"PiP is not supported on this device");
544554
}
545555
}
546556

547557
if (_pipController) {
548558
if (enabled && ![_pipController isPictureInPictureActive]) {
559+
NSLog(@"Starting PiP");
549560
[_pipController startPictureInPicture];
550561
} else if (!enabled && [_pipController isPictureInPictureActive]) {
562+
NSLog(@"Stopping PiP");
551563
[_pipController stopPictureInPicture];
552564
}
565+
} else {
566+
NSLog(@"PiP controller is nil, cannot start/stop PiP");
553567
}
568+
} else {
569+
NSLog(@"iOS version < 9.0, PiP not available");
554570
}
555571
#endif
556572
}
@@ -622,6 +638,9 @@ - (void)pictureInPictureControllerDidStopPictureInPicture:(AVPictureInPictureCon
622638
- (void)pictureInPictureController:(AVPictureInPictureController *)pictureInPictureController failedToStartPictureInPictureWithError:(NSError *)error {
623639
// PiP開始失敗時の処理
624640
NSLog(@"PiP failed to start: %@", error);
641+
NSLog(@"Error domain: %@", error.domain);
642+
NSLog(@"Error code: %ld", (long)error.code);
643+
NSLog(@"Error userInfo: %@", error.userInfo);
625644
}
626645

627646
#pragma mark - Remote Command Center

0 commit comments

Comments
 (0)