【发布时间】:2012-06-06 08:11:27
【问题描述】:
在我的应用程序中,我从 UITableview 中的服务器获取视频链接。所有这些链接都存储在 Textfile 中的服务器上,我从服务器中获取所有这些链接,并将每个链接分配给 UITableview 中的单元格。所有这些我都成功完成但我希望当我单击 UITableview 中的任何单元格时,它会在下一个视图中播放视频。这是我的代码。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
nextview *dvController = [[nextview alloc] initWithNibName:@"nextview" bundle:nil];
[self presentModalViewController:dvController animated:YES];
strFile = [Listdata objectAtIndex:indexPath.row];
NSLog(@"test=%@",strFile);
[dvController release];
}
在下一个视图中,我将存储在“strFile”中的链接分配给 MPMoviePlayerController,这是我的代码。
-(void)viewDidAppear:(BOOL)animated
{
NSLog(@"mytest=%@",strFile);
NSURL *url = [NSURL URLWithString:strFile];
NSLog(@"myurl=%@",url);
myplayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
myplayer.view.frame = CGRectMake(0, 0,900, 700);
[self.view addSubview:myplayer.view];
[myplayer play];
}
在 NSlog 中我看到了链接,但它没有在 MPMoviePlayerController 中播放。任何人都可以提前指导我犯了什么错误。谢谢。
【问题讨论】:
-
向我们展示
mytest在viewDidAppear:方法中为您打印的内容。 -
在 nslog mytest 中显示这个 mytest=youtube.com/watch?v=kJSkmmUhpHs
-
你确定视频可以被iOS播放吗?
标签: iphone ios ipad uitableview mpmovieplayercontroller