iphone - 如何在 Ipad 中播放来自 URL 的视频?

标签 iphone ios ipad uitableview mpmovieplayercontroller

在我的应用程序中,我从 UITableview 中的服务器获取视频链接。所有这些链接都存储在文本文件中的服务器上,我从服务器中逐一获取所有这些链接,并将每个链接分配给 UITableview 中的单元格。所有这些我都成功完成了但我希望当我单击 UITableview 中的任何单元格时,它会在下一个 View 中播放视频。这是我的代码。

- (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];
  }

在下一个 View 中,我将存储在“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 中播放。任何人都可以指导我我犯了什么错误。提前感谢。

最佳答案

@prince:你能告诉我你在 NSLog 中得到的 url 是什么吗??我想你弄错了网址。

我们可以通过以下方式获取 url

url = [NSURL fileURLWithPath:strUrl];

其他

url = [NSURL URLWithString:strUrl];

尝试一次。

关于iphone - 如何在 Ipad 中播放来自 URL 的视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10910458/

相关文章:

ios - 美国东部时间 11 月 4 日至 5 日的夏令时问题

iphone - 仅在存档时使用 iPhone Target 进行部署

ios - 如何在不依赖通知的情况下获取键盘高度

iphone - Xcode/iOS 模拟器 : Trigger significant location change manually

ios - 从字典数组中删除键值的重复项

c++ - 专用队列上的 GCD block 停止执行大型 SQLite3 数据库

ios - touches在约束范围内移动?

iphone - 非 ARC 和弱属性 - ios 5

iphone - 导航栏外的区域在 iOS 中不可点击

ios - 如何在 UIScrollView 中获取内容 View 以使用自动布局填充父级