[翻译] ALMoviePlayerController
ALMoviePlayerController

ALMoviePlayerController is a drop-in replacement for MPMoviePlayerController that exposes the UI elements and allows for maximum customization.
ALMoviePlayerController是MPMoviePlayerController的子类,允许你进行最大程度的定制.
Preview
ALMoviePlayerController on iPad, iOS 7.0

ALMoviePlayerController on iPhone, iOS 6.1

Features
- Drop-in replacement for
MPMoviePlayerController 继承自MPMoviePlayerController - Many different customization options, or you can go with the stock Apple look
- Portrait and landscape support 支持横竖屏
- Universal (iPhone and iPad) support 支持语言全球化
- iOS 5.0 - iOS 7 support 支持iOS5 - iOS7
- Lightweight, stable component with small memory footprint 轻量级
Installation
Installation is easy. 安装很简单
Cocoapods
- Add
pod 'ALMoviePlayerController', '~>0.3.0'to your Podfile 将ALMoviePlayerController添加到你的Podfile当中 #import <ALMoviePlayerController/ALMoviePlayerController.h>in your view of choice 将<ALMoviePlayerController/ALMoviePlayerController.h>导入到你的头文件中
Manually
- Download the ZIP from Github and copy the ALMoviePlayerController directory to your project 下载ZIP包
- Link the
QuartzCore.frameworkandMediaPlayer.frameworklibrary in your project's Build Phases 链接上QuartzCore.framework 与 MediaPlayer.framework #import "ALMoviePlayerController.h"in your view of choice 导入"ALMoviePlayerController.h"即可
Tested Environments
ALMoviePlayerController has been tested to work on iOS 5.0, 5.1 and 6.0 (simulator), and iOS 6.1 and 7.0 (device). ALMoviePlayerController requires that ARC be enabled.
ALMoviePlayerController在iOS5.0,iOS5.1以及6.0,7.0上测试过,ALMoviePlayerController需要开启ARC.
Example Usage
The process is as follows:
使用流程:
- Create an
ALMoviePlayerControllermovie player and assign yourself as its delegate 创建出实例对象并设置好代理 - Create the
ALMoviePlayerControlscontrols (and optionally customize) 创建出ALMoviePlayerControls(可选) - Assign the controls to the movie player 将控制器赋值给播放器
- Set the movie player's
contentURL, which will start playing the movie 设置好电影播放的文件URL地址,用以控制电影开始播放 - On device rotation, adjust movie player frame if it's not in fullscreen (when in fullscreen, rotation is handled automatically)
- Implement
ALMoviePlayerControllerdelegate methods 实现ALMoviePlayerController代理方法
In code:
@property (nonatomic, strong) ALMoviePlayerController *moviePlayer; //... // create a movie player
self.moviePlayer = [[ALMoviePlayerController alloc] initWithFrame:self.view.frame];
self.moviePlayer.delegate = self; //IMPORTANT! // create the controls
ALMoviePlayerControls *movieControls = [[ALMoviePlayerControls alloc] initWithMoviePlayer:self.moviePlayer style:ALMoviePlayerControlsStyleDefault]; // optionally customize the controls here...
/*
[movieControls setBarColor:[UIColor colorWithRed:195/255.0 green:29/255.0 blue:29/255.0 alpha:0.5]];
[movieControls setTimeRemainingDecrements:YES];
[movieControls setFadeDelay:2.0];
[movieControls setBarHeight:100.f];
[movieControls setSeekRate:2.f];
*/ // assign the controls to the movie player
[self.moviePlayer setControls:movieControls]; // add movie player to your view
[self.view addSubview:self.moviePlayer.view]; //set contentURL (this will automatically start playing the movie)
[self.moviePlayer setContentURL:[NSURL URLWithString:@"http://archive.org/download/WaltDisneyCartoons-MickeyMouseMinnieMouseDonaldDuckGoofyAndPluto/WaltDisneyCartoons-MickeyMouseMinnieMouseDonaldDuckGoofyAndPluto-HawaiianHoliday1937-Video.mp4"]];
On rotation:
if (!self.moviePlayer.isFullscreen) {
[self.moviePlayer setFrame:frame];
//"frame" is whatever the movie player's frame should be at that given moment
}
Note: you MUST use [ALMoviePlayerController setFrame:] to adjust frame, NOT[ALMoviePlayerController.view setFrame:]
Delegate methods
@required
- (void)moviePlayerWillMoveFromWindow;
@optional
- (void)movieTimedOut;
Note: moviePlayerWillMoveFromWindow is required for fullscreen mode to work properly. It should be used to re-add the movie player to your view controller's view (because during the transition to fullscreen, it was moved to [[UIApplication sharedApplication] keyWindow].
Your code might look something like this:
- (void)moviePlayerWillMoveFromWindow {
if (![self.view.subviews containsObject:self.moviePlayer.view])
[self.view addSubview:self.moviePlayer.view];
[self.moviePlayer setFrame:frame];
}
Controls Properties
ALMoviePlayerControls has the following editable properties:
/**
The style of the controls. Can be changed on the fly. Default value is ALMoviePlayerControlsStyleDefault
*/
@property (nonatomic, assign) ALMoviePlayerControlsStyle style; /**
The state of the controls.
*/
@property (nonatomic, readonly) ALMoviePlayerControlsState state; /**
The color of the control bars. Default value is black with a hint of transparency.
*/
@property (nonatomic, strong) UIColor *barColor; /**
The height of the control bars. Default value is 70.f for iOS7+ and 50.f for previous versions.
*/
@property (nonatomic, assign) CGFloat barHeight; /**
The amount of time that the controls should stay on screen before automatically hiding. Default value is 5 seconds.
*/
@property (nonatomic, assign) NSTimeInterval fadeDelay; /**
The rate at which the movie should fastforward or rewind. Default value is 3x.
*/
@property (nonatomic, assign) float seekRate; /**
Should the time-remaining number decrement as the video plays? Default value is NO.
*/
@property (nonatomic) BOOL timeRemainingDecrements; /**
Are the controls currently showing on screen?
*/
@property (nonatomic, readonly, getter = isShowing) BOOL showing;
Controls Styles
typedef enum {
/** Controls will appear in a bottom bar */
ALMoviePlayerControlsStyleEmbedded,
/** Controls will appear in a top bar and bottom bar */
ALMoviePlayerControlsStyleFullscreen,
/** Controls will appear as ALMoviePlayerControlsStyleFullscreen when in fullscreen and ALMoviePlayerControlsStyleEmbedded at all other times */
ALMoviePlayerControlsStyleDefault,
/** Controls will not appear */
ALMoviePlayerControlsStyleNone,
} ALMoviePlayerControlsStyle;
Suggestions?
If you have any suggestions, let me know! If you find any bugs, please open a new issue.
Contact Me
You can reach me anytime at the addresses below. If you use the library, feel free to give me a shoutout on Twitter to let me know how you like it. I'd love to hear your thoughts.
Github: alobi
Twitter: @lobi4nco
Email: anthony@lobian.co
Credits & License
ALMoviePlayerController is developed and maintained by Anthony Lobianco (@lobi4nco). Licensed under the MIT License. Basically, I would appreciate attribution if you use it.
Enjoy!
(⌐■_■)
[翻译] ALMoviePlayerController的更多相关文章
- 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...
- 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...
- [翻译]开发文档:android Bitmap的高效使用
内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...
- 【探索】机器指令翻译成 JavaScript
前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...
- 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...
- 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...
- 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...
- 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?
0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...
- ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点
在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...
随机推荐
- Java并发编程笔记之ThreadLocal源码分析
多线程的线程安全问题是微妙而且出乎意料的,因为在没有进行适当同步的情况下多线程中各个操作的顺序是不可预期的,多线程访问同一个共享变量特别容易出现并发问题,特别是多个线程需要对一个共享变量进行写入时候, ...
- tomcat与jboss等容器的区别
1.JBoss 是 J2EE 应用服务器,而 Tomcat 只是一个 Servlet 容器,或者说是一个简单的 J2EE 应用服务器. JBoss 中的 Servlet 容器还是 Tomcat. 与 ...
- vue 2.x之组件的数据传递(一)
这是根据官方提供的脚手架vue-cli搭建,通过简单的案例来介绍vue数据的传递的方式,根据自己平时用到的,来做简单的总结: 1.父组件传递数据给子组件 父组件传递数据给子组件,需要把子组件引入,并挂 ...
- Java操作elasticsearch
使用 Maven 工程,我的 pom 文件如下所示: <dependencies> <dependency> <groupId>org.elasticsearch& ...
- C#/Net代码精简优化技巧
(一) 在我们写代码的时候可以使用一些小的技巧来使代码变得更加简洁,易于维护和高效.下面介绍几种在C#/Net中非常有用的一些编程技巧. 1 空操作符(??) 在程序中经常会遇到对字符串或是对象判断n ...
- JS数组sort比较函数
转载:http://www.cnblogs.com/ljchow/archive/2010/06/30/1768683.html 我们知道,数组的sort方法可以对数组元素进行排序,默认是按ASCII ...
- AVFoundation-视频录制以及拍照
一般如果UI和UE在设计时只要求功能,对相机界面没什么要求的话,个人觉得调用系统相机(UIImagePickerController)就可以满足我们的需求比如照相或者录制视频,但是考虑界面美观性,有时 ...
- JS 重写alert,使之能输出多个参数
windows._alert = windows.alert; windows.alert = function(){ _alert = (Array.prototype.slice(argument ...
- PHP module 安装
Part1:不重新安装php,安装zlib模块--------20171229 先安装zlib源码包 指定到目录 一台服务器,编译PHP时未设置参数,导致缺少zlib扩展,无法执行解压缩,错误信息是: ...
- SpringBoot(六) Web Applications: Embedded Containers(嵌入式容器)
参考 文档: 28.4 Embedded Servlet Container Support