所以我對編碼一般都很陌生(我的背景是在視頻製作中),而且我的任務是創建一個iPhone應用程序。實際上,Xcode在教程等方面非常簡單,但是我已經遇到了一些我不知道的東西。無論如何...在這裏。爲什麼我的應用不能正確解析視頻鏈接?
我遵循YouTube上關於解析iOS中的XML的教程。很棒。但是,本教程將XML解析爲標籤。那部分工作完美。但是,我試圖使用自定義的XML文檔來解析播客RSS提要,並且我希望視頻的鏈接轉到播放按鈕,而不是填寫標籤。所以我認爲我可以將已經工作的鏈接傳遞給使用MPMoviePlayerViewController的按鈕。沒有工作。
它給出了有關將NSString作爲URL傳遞的錯誤。然後我使用NSUrl來製作視頻鏈接。沒有錯誤,但視頻不播放。我做錯了什麼想法?
我包含的唯一代碼是DetailViewController.m文件,與其他所有工作一樣,即使鏈接正確顯示在標籤中。它只是沒有正確連接到按鈕。當您點擊模擬器中的播放按鈕時,它會啓動電影播放器,並只顯示「加載...」屏幕。任何幫助將不勝感激。
#import "DetailViewController.h"
#import <MediaPlayer/MediaPlayer.h>
@implementation DetailViewController
@synthesize theList;
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = theList.title;
theTitle.text = theList.title;
theAuthor.text = theList.author;
playAudio.text = theList.audio;
playVideo.text = theList.video;
}
- (void)viewDidUnload
{
[super viewDidUnload];
}
- (IBAction)playVid:(id)sender {
NSURL *playVid = [NSURL URLWithString:theList.video];
MPMoviePlayerViewController *mpViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:playVid];
[mpViewController shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortrait];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:YES];
[self presentMoviePlayerViewControllerAnimated:mpViewController];
}
@end
你確定你得到一個有效的NSURL實例嗎? – 2012-07-05 18:21:01
我不確定。我不知道如何檢查。我知道URL是正確的,因爲它正確傳遞到標籤。你知道任何有關如何檢查NSURL接收的教程嗎? – user1499854 2012-07-05 19:08:52
在創建'playVid'之後添加'NSLog(@「%@」,playVid);並查看控制檯中顯示的內容。 – 2012-07-05 19:11:20