网路视频播放-ios

-(void)playMovie

{



    NSURL *urls = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.3dhr.gov.cn%@",[self.detailDic objectForKey:@"m_path"]]];

    movie = [[MPMoviePlayerController alloc]initWithContentURL:urls];

    movie.controlStyle = MPMovieControlStyleDefault;

    [movie prepareToPlay];

    [movie.view setFrame:CGRectMake(0, 0, 320, [UIScreen mainScreen].bounds.size.height-60)];

    movie.movieSourceType = MPMovieSourceTypeFile;

    movie.initialPlaybackTime = -1;

    [self.view addSubview:movie.view];

    //注册一个播放结束的通知

    [[NSNotificationCenter defaultCenter] addObserver:self

                                             selector:@selector(myMovieFinishedCallback:)

                                                 name:MPMoviePlayerPlaybackDidFinishNotification

                                               object:movie];

    [movie play];

//    movie.shouldAutoplay =YES;

    

    UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"关闭" style:UIBarButtonItemStyleBordered target:self action:@selector(closeMovie)];

    [self.navigationItem setRightBarButtonItem:rightBarButtonItem];

    [rightBarButtonItem release];

}

 

你可能感兴趣的:(ios)