[翻译] 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

  1. Add pod 'ALMoviePlayerController', '~>0.3.0' to your Podfile 将ALMoviePlayerController添加到你的Podfile当中
  2. #import <ALMoviePlayerController/ALMoviePlayerController.h> in your view of choice 将<ALMoviePlayerController/ALMoviePlayerController.h>导入到你的头文件中

Manually

  1. Download the ZIP from Github and copy the ALMoviePlayerController directory to your project 下载ZIP包
  2. Link the QuartzCore.framework and MediaPlayer.framework library in your project's Build Phases 链接上QuartzCore.framework 与 MediaPlayer.framework
  3. #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:

使用流程:

  1. Create an ALMoviePlayerController movie player and assign yourself as its delegate 创建出实例对象并设置好代理
  2. Create the ALMoviePlayerControls controls (and optionally customize) 创建出ALMoviePlayerControls(可选)
  3. Assign the controls to the movie player 将控制器赋值给播放器
  4. Set the movie player's contentURL, which will start playing the movie 设置好电影播放的文件URL地址,用以控制电影开始播放
  5. On device rotation, adjust movie player frame if it's not in fullscreen (when in fullscreen, rotation is handled automatically) 
  6. Implement ALMoviePlayerController delegate 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!

(⌐■_■)

 

时间: 2024-08-03 04:49:00

[翻译] ALMoviePlayerController的相关文章

[翻译]JDK 8 兼容性指南

翻译官方文档,删除部分可忽略. 译者:坤谷,井桐,激酶 兼容性是一个复杂的问题. 本文介绍了Java平台潜在的三种不兼容问题: 源码: 源码兼容性问题关注Java源代码转换成class文件是否兼容,包括代码是否仍然可编译. 二进制: 在Java语言规范中,二进制兼容性定义为:"类的改变是二进制兼容的(或者不破坏二进制兼容性),是指如果改变前的类的二进制在链接时没有错误,那么改变后的类在链接时仍然没有错误." 行为 : 行为兼容性包括在运行时执行的代码的语义. 欲了解更多信息,请参阅Op

java.security.Guard翻译

  Overview Package  Class Use Tree Deprecated Index Help JavaTM 2 PlatformStd. Ed. v1.4.2  PREV CLASS   NEXT CLASSFRAMES    NO FRAMES     All Classes SUMMARY: NESTED | FIELD | CONSTR | METHODDETAIL: FIELD | CONSTR | METHOD java.security Interface Gua

翻译CFSSL相关操作文档

我发现国内这个CFSSL资料蛮少的. 但如果深入到K8S认证之后,这块知识又必不可少. (OPENSSL也可实现,但好像不是主流) 于是花了两天快速翻译了一下几个文档. 贡献给有需要的同仁. 如有错误(肯定有!),欢迎提正. 百度网盘共享地址: https://pan.baidu.com/s/1skAQtAH

如何这段C#代码翻译成VB代码?谢谢!

问题描述 如何这段C#代码翻译成VB代码?谢谢! private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { //自动点击弹出确认或弹出提示 IHTMLDocument2 vDocument = (IHTMLDocument2)webBrowser1.Document.DomDocument; vDocument.parentWindow.execScrip

php-java和PHP有纯中文的官方手册吗?还是只有部分的翻译?

问题描述 java和PHP有纯中文的官方手册吗?还是只有部分的翻译? java和PHP有纯中文的官方手册吗?还是只有部分的翻译?我英文不好,能不能学呢? 解决方案 http://cn2.php.net/manual/zh/index.php 解决方案二: java的JDK有中文版的API,PHP网上也有中文手册.现在网络资源这么丰富,只有肯上心,学东西还是很容易的. 选定一个完整的视频教程,跟着练习,上手是很容易的. 我就是2010年暑假跟着传智播客视频教程自学的Java,现在已经很熟练了.祝好

傲游浏览器怎么翻译网页

  步骤一:没有傲游浏览器的童鞋 步骤二:点开下拉====勾选"翻译". 步骤三:输入你想要的翻译的网址,选定你想翻译的内容 步骤四:耐心等待翻译结果

Word 2010中的“翻译字典”

  1.打开一篇文字文档,并且里面与你有需要翻译的文字,例如,我们这里先选择一篇中文散文; 2.在功能区点击"审阅"选项卡,选择"语言"区域的"翻译"选项组,单击"翻译所选文字"; 3.单击"审阅"功能卡,点击"语言"区域的"翻译"选项组,在弹出的下拉菜单中选择"选择转换语言"; 4.此时窗口会弹出一个"翻译语言选项"的对话框,

Word每一页的左边显示英语右边显示中文翻译

  现在,您想实现的效果是,在每一页里面,左边是英文,右边是对应的翻译好的中文.像这样的排版方式,可以方便我们更好的学习英语. ①使用分栏的是不科学的 要解决这个问题,很多人第一时间就会想到分栏,想把英文放在栏的左边,中文放在栏的右边.然而,这是可行的,却是不科学的. 因为,使用Word里面的自动分栏,原文英文和翻译后的中文,很难一一对应,造成学习上的困难.另外,如果您想再排版实现一一对应,那么,难度是非常大. ②使用文本框也是不合理的 以上方法难以实现.很多人会想到使用文本框的办法. 即在Wo

360浏览器如何翻译英文网页

  整个网页翻译: 1.打开360浏览器,在浏览器中打开你想浏览的英文网站,选择浏览器上面的翻译三角符号. 2.选择第一项,翻译当前网页,就会开始翻译了. 3.翻译完后,就可以看到全部是中文了. 单个句子翻译: 1.同样选择浏览器上面的翻译,选择第二项翻译文字. 2.在弹出的翻译对话框中,将要翻译的英文复制到文本框中,点击下面的翻译. 3.翻译完后,翻译的结果就在下面了,很方便的.