3
因此,我的應用程序中彈出了一個警報視圖,點擊視頻按鈕時視頻應該播放,但模擬器中沒有任何反應。我不想在設備上測試它,直到它在模擬器中運行。這是下面的代碼,據我可以告訴它應該工作。它到達Log語句並輸出到控制檯,但視頻不播放。有任何想法嗎?獲取視頻在模擬器中播放
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex: (NSInteger)buttonIndex{
if (buttonIndex == 1) {
NSURL *url = [NSURL URLWithString:@"http://srowley.co.uk/endyVid.mp4"];
MPMoviePlayerController *player = [[[MPMoviePlayerController alloc] initWithContentURL:url] autorelease];
//---play movie---
[player setFullscreen:YES];
[self.view addSubview:[player view]];
NSLog(@"Player Should play!");
[player play];
}
}
把在dodn't改變任何東西:( – SamRowley 2010-10-07 21:20:47
不能創建玩家爲自動釋放的對象,或者它deallocs它得到上場機會之前,將其分配到一個屬性或伊娃和釋放當用戶完成觀看電影時 – 2010-10-07 21:27:28
此外,您可能想要使用didDismissWithButtonIndex:而不是clickedButtonAtIndex :.前者在運行之前等待警報視圖消失,這看起來像是在播放視頻之前想要的。 – 2010-10-07 21:34:32