在我的應用程序中,我錄製視頻並播放它。大多數時候,視頻播放效果不錯,但有時在播放視頻的中間,當我在日誌中按下「完成」按鈕時「UIStatusBarStyleBlackTranslucent在此設備上不可用。」味精顯示,但它如何產生,我不知道,當這種味精生成我的應用程序變成「黑色」,我不得不從背景中刪除它。其餘的時間我的視頻很好地完美。 在我的info.plist文件中,我更改了必要的狀態欄設置,但在結果中無效。iPhone:當msg「UIStatusBarStyleBlackTranslucent在此設備上不可用時,應用程序變爲」黑色「。顯示
我想提一下,我正在從iPad調試我的應用程序。
並且此msg不會每次生成。 我不知道爲什麼會顯示此消息。 下面的代碼在按下完成按鈕上運行。
- (void)moviePlaybackDidFinish:(NSNotification*)notification
{
[self stopMovie];
NSLog(@"Start Timer Again");
// [btnVideo setTitle:@"Start Recording" forState:UIControlStateNormal];
[btnVideo setImage:[UIImage imageNamed:@"Record Button-iPad.png"] forState:UIControlStateNormal];
NSURL *url = [NSURL fileURLWithPath:@"/dev/null"];
NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat: 44100.0], AVSampleRateKey,
[NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey,
[NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
[NSNumber numberWithInt: AVAudioQualityMax], AVEncoderAudioQualityKey,
nil];
NSError *error;
if (recorder) {
recorder = nil;
[recorder release];
}
recorder = [[AVAudioRecorder alloc] initWithURL:url settings:settings error:&error];
if (recorder) {
[recorder prepareToRecord];
recorder.meteringEnabled = YES;
[recorder record];
}
NSString *str = [[NSUserDefaults standardUserDefaults] valueForKey:@"IMAGE_MOVEMENT"];
NSLog(@"image movement %@",str);
if(str == @"EASY")
{
NSLog(@"inside easy image");
[self validateTimer];
levelTimer = [NSTimer scheduledTimerWithTimeInterval:0.03 target:self selector:@selector(levelTimerCallbackEasy:) userInfo:nil repeats: YES];
}
else if(str == @"MEDIUM")
{
NSLog(@"inside medium image");
[self validateTimer];
levelTimerMedium = [NSTimer scheduledTimerWithTimeInterval:0.03 target:self selector:@selector(levelTimerCallbackMedium:) userInfo:nil repeats:YES];
}
else if(str == @"HARD")
{
NSLog(@"inside hard image");
[self validateTimer];
levelTimerHard = [NSTimer scheduledTimerWithTimeInterval:0.03 target: self selector: @selector(levelTimerCallbackHard:) userInfo: nil repeats: YES];
}
}
- (void)stopMovie
{
NSLog(@"Stop Movie");
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerWillExitFullscreenNotification
object:moviePlayer];
// This trick is necessary, otherwise the screen remains black or will
// flicker when you try to play the next video.
[moviePlayer pause];
[moviePlayer stop];
moviePlayer.initialPlaybackTime = -1.0;
moviePlayer = nil;
NSString *recorderFilePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
recorderFilePath = [recorderFilePath stringByAppendingPathComponent:@"tempRecording.caf"];
if ([[NSFileManager defaultManager] fileExistsAtPath:recorderFilePath]) {
[[NSFileManager defaultManager] removeItemAtPath:recorderFilePath error:nil];
}
NSString *movieFilePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
movieFilePath = [movieFilePath stringByAppendingPathComponent:@"export.mov"];
if ([[NSFileManager defaultManager] fileExistsAtPath:movieFilePath]) {
[[NSFileManager defaultManager] removeItemAtPath:movieFilePath error:nil];
}
NSString *videoFilePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
videoFilePath = [videoFilePath stringByAppendingPathComponent:@"output.mp4"];
if ([[NSFileManager defaultManager] fileExistsAtPath:videoFilePath]) {
[[NSFileManager defaultManager] removeItemAtPath:videoFilePath error:nil];
}
NSURL *urls = [NSURL fileURLWithPath:recorderFilePath];
NSError *err = nil;
if (voiceRecorder) {
voiceRecorder = nil;
[voiceRecorder release];
}
voiceRecorder = [[ AVAudioRecorder alloc] initWithURL:urls settings:recordSetting error:&err];
//[recorder setMeteringEnabled:YES];
if(!voiceRecorder){
NSLog(@"recorder: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
UIAlertView *alert =
[[UIAlertView alloc] initWithTitle: @"Warning"
message: [err localizedDescription]
delegate: nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
return;
}
//prepare to record
[voiceRecorder setDelegate:self];
[voiceRecorder prepareToRecord];
//voiceRecorder.meteringEnabled = YES;
}
如果您有任何問題,請提供給我。
thanx提前。
直到我知道UIStatusBarStyleBlackTranslucent被蘋果不贊成使用。所以你需要找到一個替代...此外...你給的代碼是無關你的問題...問題是在別的地方... – DShah 2012-02-14 06:06:45