wys163
V2EX  ›  问与答

大神们,ios 自动播放视频的叫什么效果?怎么实现的?

  •  
  •   wys163 · Jun 26, 2016 · 3371 views
    This topic created in 3635 days ago, the information mentioned may be changed or developed.

    比如朋友圈里面的那种效果,在列表里面自动播放视频而且没声音

    1 replies    2016-06-26 15:22:10 +08:00
    userchuxu
        1
    userchuxu  
       Jun 26, 2016
    一:// 点击播放视频.
    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
    // 9.0 之后的视频播放.

    // 获得视频播放地址.
    HMVideo *video = self.videos[indexPath.row];

    NSURL *url = [NSURL URLWithString:video.url];

    AVPlayerViewController *av = [[AVPlayerViewController alloc] init];

    [av.player play];

    // 跳转控制器
    [self presentViewController:av animated:YES completion:^{
    //
    }];
    }
    二:// MPMoviePlayerViewController 使用.
    - (void)testWithIndexPath:(NSIndexPath *)indexPath
    {
    // 获得视频播放地址.
    HMVideo *video = self.videos[indexPath.row];

    NSURL *url = [NSURL URLWithString:video.url];

    // 1.实例化视频播放器. MPMoviePlayerViewController
    MPMoviePlayerViewController *mv = [[MPMoviePlayerViewController alloc] initWithContentURL:url];

    // 跳转控制器.
    // 注意:不能添加全局断点.
    [self presentMoviePlayerViewControllerAnimated:mv];

    }
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4169 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 05:21 · PVG 13:21 · LAX 22:21 · JFK 01:21
    ♥ Do have faith in what you're doing.