0
回答
iphone播放远程与本地视频
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   

最近在做一个在线播放的软件, 发现远程视频的播放与本地播放没什么区别, 都是得到一个NSURL.

 

下面是本地得到NSURL代码:

- (id)initWithPath:(NSString *)moviePath
{
  if (self = [super init])
  {
    movieURL = [NSURL fileURLWithPath:moviePath];    
    [movieURL retain];
  }
  return self;
}
 

下面是远程地址得到NSURL代码:

- (id)initWithURL:(NSURL *)URL
{
  if (self = [super init])
  {
    movieURL = URL;
    [movieURL retain];
 
  }
  return self;
}
 

 

下面是播放视频代码:

- (void)loadMoviePlayer
{  
/*
  // Play movie from app bundle
  NSString *path = [[NSBundle mainBundle] pathForResource:@"Movie-1" ofType:@"mp4" inDirectory:nil];
  moviePlayer = [[[CustomMoviePlayerViewController alloc] initWithPath:path] autorelease];
*/
 
  // Play movie from URL
  NSURL *movieURL = [NSURL URLWithString:@"http://someurlsomewhere.com/movie.mp4"];
  moviePlayer = [[[CustomMoviePlayerViewController alloc] initWithURL:movieURL] autorelease];
 
  // Show the movie player as modal
  [self presentModalViewController:moviePlayer animated:YES];
 
  // Prep and play the movie
  [moviePlayer readyPlayer];    
}
 

是不是觉得很简单呀,其实iphone下的东西就是这么简单的,努力学习。


原文链接:http://blog.csdn.net/favormm/article/details/5958674
<无标签>
举报
长平狐
发帖于5年前 0回/328阅
顶部