आईओएस 3.2 या बाद में मान लें। शुरू में छिपे हुए नियंत्रणों के साथ एक कदम चलाने के लिए आदेश का उचित अनुक्रम क्या है। जब फिल्म चल रही है, तो उपयोगकर्ता के पास स्क्रीन पर टैग करने और नियंत्रण दिखाने का विकल्प होता है।MPMoviePlayerController मूवी से पहले नियंत्रण कैसे छिपाना है?
धन्यवाद!
मेरे (नियंत्रण छिपी नहीं) कोड:
- (void)playMovie
{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Test" ofType:@"m4v"]];
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
// Register to receive a notification when the movie has finished playing.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieDone:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieState:)
name:MPMoviePlayerNowPlayingMovieDidChangeNotification
object:moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieReady:)
name:MPMoviePlayerLoadStateDidChangeNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willEnterFullScreen:) name:MPMoviePlayerWillEnterFullscreenNotification object:moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willExitFullScreen:) name:MPMoviePlayerWillExitFullscreenNotification object:moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFinishPlayback:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) {
moviePlayer.controlStyle = MPMovieControlStyleDefault; // MPMovieControlStyleNone MPMovieControlStyleEmbedded MPMovieControlStyleFullscreen MPMovieControlStyleDefault
moviePlayer.scalingMode = MPMovieScalingModeAspectFill; // MPMovieScalingModeAspectFit MPMovieScalingModeAspectFill
}
}
- (void) movieReady:(NSNotification*)notification
{
MPMoviePlayerController *moviePlayer = [notification object];
if ([moviePlayer loadState] != MPMovieLoadStateUnknown) {
// Remove observer
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerLoadStateDidChangeNotification
object:nil];
// When tapping movie, status bar will appear, it shows up
// in portrait mode by default. Set orientation to landscape
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:NO];
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
// Add movie player as subview
[[self view] addSubview:[moviePlayer view]];
// Play the movie
[moviePlayer play];
[moviePlayer setFullscreen:YES animated:YES];
}
}
अच्छी नोक। मैंने यह भी पाया कि अगर मैं नियंत्रण शैली को 'एमपीएमवी कंट्रोल स्टाइलफुलस्क्रीन' पर खेलने के तुरंत बाद सेट करता हूं, तो यह वही परिणाम प्राप्त करता है। तो शायद मनमानी 1 सेकंड देरी निर्दिष्ट करने का कोई कारण नहीं है? – curthipster
एक दूसरी देरी मेरे लिए भी काम करती है। मैंने आधे सेकेंड की कोशिश की, लेकिन वह बहुत तेज था। –
हां, मुझे अभी भी देरी की आवश्यकता है कि मुझे इस तरह की देरी शुरू करने की आवश्यकता क्यों है। –