苹果开发 笔记(41)MPMoviePlayerController

今天看了一些视频的资料,和之前音频处理也是属于同一章节的内容。这部分内容讲了一些视频播放方面的内容。参考了案例调试了一下,敲打了一下。书里面没有讲解旋转和全屏的特性,在看一些资料和自己调试还是有点差距,困惑这个问题。
在学ios的时候, 这部分属于多媒体的一部分,参考一些书,发现一些会发现一些旧的API 被遗弃了。对于新的sdk 内容这些部分已经不适应了。做法有点旧,可惜是书没有篇幅去介绍全屏的做法。以及使用webView 后调用的方式。
下面 是一个基本播放视频的code,没有实现全屏。这个横屏后还没处理好。今天就先留下这些问题。

#import "ViewController.h"
#import <MediaPlayer/MPMoviePlayerController.h>

@interface ViewController ()

//@properter (n)MPMoviePlayerController * player;
@property (nonatomic,strong) MPMoviePlayerController *player;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    NSURL *url = [NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"];
    self.player =[[MPMoviePlayerController alloc]initWithContentURL:url];
    self.player.fullscreen = YES;


    CGRect winRect = [[UIScreen mainScreen] applicationFrame];
    CGRect rect = CGRectMake(0,0,winRect.size.height, winRect.size.width);
    self.player.controlStyle = MPMovieControlStyleDefault;
    self.player.view.frame = rect;
    self.player.view.center = CGPointMake(rect.size.width/2, rect.size.height/2);
    [self.player.view setTransform:CGAffineTransformMakeRotation(M_PI/2)];
   // self.player.scalingMode = MPMovieScalingModeAspectFill;

    [self.player play];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playCompleteFun:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];

    [self.view addSubview:self.player.view];
}


-(void) playCompleteFun:(NSNotification *) notification
{

    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:nil];

}






- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值