I am porting an application to iOS 8. I had some code to play a video that was working before but now it doesn't.
When I run it, I get the following errors:
(
"<NSLayoutConstraint:0x7faba2df5940 H:|-(34)-[MPKnockoutButton:0x7faba2e6d750](LTR) (Names: '|':_UIBackdropContentView:0x7faba2dc38c0 )>",
"<NSLayoutConstraint:0x7faba2d51780 H:[MPKnockoutButton:0x7faba2e6d750]-(34)-[MPDetailSlider:0x7faba2dc6440](LTR)>",
"<NSLayoutConstraint:0x7faba2d5b7f0 H:[MPDetailSlider:0x7faba2dc6440]-(34)-[UIView:0x7faba2dc4060](LTR)>",
"<NSLayoutConstraint:0x7faba2dc5da0 UIView:0x7faba2dc4060.right == _UIBackdropView:0x7faba2dbfdc0.right>",
"<NSLayoutConstraint:0x7faba2dc58d0 H:|-(0)-[_UIBackdropView:0x7faba2dbfdc0] (Names: '|':MPVideoPlaybackOverlayView:0x7faba2dbf6a0 )>",
"<NSLayoutConstraint:0x7faba2dc5950 H:[_UIBackdropView:0x7faba2dbfdc0]-(0)-| (Names: '|':MPVideoPlaybackOverlayView:0x7faba2dbf6a0 )>",
"<NSLayoutConstraint:0x7faba2df9b10 H:[MPVideoPlaybackOverlayView:0x7faba2dbf6a0(0)]>",
"<NSAutoresizingMaskLayoutConstraint:0x7faba2dfbfa0 h=-&- v=-&- _UIBackdropContentView:0x7faba2dc38c0.midX == _UIBackdropView:0x7faba2dbfdc0.midX>",
"<NSAutoresizingMaskLayoutConstraint:0x7faba2dfbff0 h=-&- v=-&- _UIBackdropContentView:0x7faba2dc38c0.width == _UIBackdropView:0x7faba2dbfdc0.width>"
)
Here's the code:
movieController = [[MPMoviePlayerController alloc]
initWithContentURL:[NSURL URLWithString:playlistUrl]];
movieController.movieSourceType = MPMovieSourceTypeStreaming;
[movieController.view setFrame:[self.playerView bounds]];
[self.playerView addSubview:movieController.view];
[movieController play];
Any thoughts?
This appears to be fixed in iOS 8.1. The error disappeared after I upgraded.
However, I did have to modify my code slightly:
movieController = [[MPMoviePlayerController alloc]
initWithContentURL:[NSURL URLWithString:playlistUrl]];
movieController.movieSourceType = MPMovieSourceTypeStreaming;
[movieController.view setTranslatesAutoresizingMaskIntoConstraints:NO];
[playerView addSubview:movieController.view];
id views = @{ @"player": movieController.view };
[playerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[player]|"
options:0
metrics:nil
views:views]];
[playerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[player]|"
options:0
metrics:nil
views:views]];
[movieController play];
I've just come across this issue myself.
I noticed the constraint warnings would appear even without the MKMoviePlayerController
view on screen and before before I ever accessed it.
This lead me to remove my calls to the thumbnail generation APIs requestThumbnailImagesAtTimes:timeOption:
and cancelAllThumbnailImageRequests
.
After using an alternate method of retrieving thumbnails the warnings stopped immediately.
I'm loading local urls though, not streaming - but I imagine the streaming mechanism is attempting to load a thumbnail somewhere and causing the issues we're seeing.
I haven't noticed any documented solutions or answers to this issue so I hope my anecdotal evidence helps.
For lazy people.
When I want to use movieController.view.frame
directly I just call
[movieController.view setTranslatesAutoresizingMaskIntoConstraints:YES];
before
[movieController prepareToPlay];
[self.view addSubview:movieController.view];
to not mess with constraints.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With