今天看了一些视频的资料,和之前音频处理也是属于同一章节的内容。这部分内容讲了一些视频播放方面的内容。参考了案例调试了一下,敲打了一下。书里面没有讲解旋转和全屏的特性,在看一些资料和自己调试还是有点差距,困惑这个问题。
在学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