MWPhotoBrowser icon indicating copy to clipboard operation
MWPhotoBrowser copied to clipboard

Depreciated MPMoviePlayerViewController

Open robhasacamera opened this issue 9 years ago • 5 comments

After importing MWPhotoBrowser into my swift project. I'm getting the following warning:

/[....]/Pods/MWPhotoBrowser/Pod/Classes/MWPhotoBrowserPrivate.h:57:5: 'MPMoviePlayerViewController' is deprecated: first deprecated in iOS 9.0 - Use AVPlayerViewController in AVKit.

robhasacamera avatar May 11 '16 02:05 robhasacamera

Would appreciate an update to fix this too :)

edenfisher avatar May 17 '16 04:05 edenfisher

Would be nice to get a fix for this as well!

mikechan1234 avatar Jun 19 '16 02:06 mikechan1234

Would be nice to get this solved

FrancescCampa avatar Sep 14 '16 14:09 FrancescCampa

I'll take a look as I delve further into a multimedia app. Might need to fork depending on #551

soundsmitten avatar Sep 27 '16 18:09 soundsmitten

I've updated the play video function to solve this issue.

`- (void)_playVideo:(NSURL *)videoURL atPhotoIndex:(NSUInteger)index {

_currentVideoPlayerViewController = [[AVPlayerViewController alloc] init];
_currentVideoPlayerViewController.player = [AVPlayer playerWithURL:videoURL];

[self presentViewController:_currentVideoPlayerViewController animated:YES completion:^{
    [_currentVideoPlayerViewController.player play];
}];
[[NSNotificationCenter defaultCenter] removeObserver:self name:AVPlayerItemDidPlayToEndTimeNotification object:_currentVideoPlayerViewController.player.currentItem];


[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(videoFinishedCallback:)
                                             name:AVPlayerItemDidPlayToEndTimeNotification
                                           object:_currentVideoPlayerViewController.player.currentItem];

}`

`- (void)videoFinishedCallback:(NSNotification*)notification {

// Remove observer
[[NSNotificationCenter defaultCenter] removeObserver:self name:AVPlayerItemDidPlayToEndTimeNotification object:_currentVideoPlayerViewController.player.currentItem];

// Clear up
[self clearCurrentVideo];

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    [self dismissViewControllerAnimated:YES completion:nil];
});

}`

- (void)clearCurrentVideo { [_currentVideoPlayerViewController.player replaceCurrentItemWithPlayerItem:nil]; [_currentVideoLoadingIndicator removeFromSuperview]; _currentVideoPlayerViewController = nil; _currentVideoLoadingIndicator = nil; [[self pageDisplayedAtIndex:_currentVideoIndex] playButton].hidden = NO; _currentVideoIndex = NSUIntegerMax; }

MubeenQazi avatar Jun 26 '18 10:06 MubeenQazi