iOS 視頻播放,ios視頻播放
功能
- 支援本地視頻&網路視頻
- 開始&暫停
- 最大化&還原
- 映像左側上下調節 : 亮度
- 映像右側上下調節 : 音量
- 左右滑動 : 快進快退
簡介
- 這是一個UIView的子類,它可以載入到你所需要的任何位置.
- 它可以是一個小視窗,也可以是一個全屏的視窗
- 支援方向識別,橫屏時自動最大化
使用載入:
匯入標頭檔#import "YVideoPlayerView.h"
yVideoPlayerView = [YVideoPlayerView initWithVideoName:@"視頻名稱1" frame:CGRectMake(0,20,200,150) path:@"http://videoPath" onViewControll:self];初始化方法+ (instancetype)initWithVideoName:(NSString *)name frame:(CGRect)frame path:(NSString *)path onViewControll:(UIViewController *)OnViewController;name : 視頻名稱frame : 視頻位置path : 視頻路徑onViewController : 載入視頻所在的ViewController -> 一般寫self
更新:
yVideoPlayerView = [yVideoPlayerView updateVideoWithName:@"視頻名稱2" path:@"http://videoPath2" onViewController:self];注意 : 這是一個對象方法- (instancetype)updateVideoWithName:(NSString *)name path:(NSString *)path onViewController :(UIViewController *)OnViewController;name : 視頻名稱path : 視頻路徑onViewController : 載入視頻所在的ViewController -> 一般寫self這裡不用重寫frame -- 參照了初始化時
提醒
- 本架構純ARC,相容的系統>=iOS6.0、iPhone\iPad橫豎屏
- 橫豎屏需要手機關閉橫豎排方向鎖定
- App至少要開啟
LandScape Left
或 LandScape Right
其中的一項. 如App其他頁面不能轉屏,用代碼鎖定!
- 在其他不需要轉屏的根視圖裡寫如下代碼:
- (UIInterfaceOrientationMask)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; }
- 在載入YVideoPlayerView的ViewController裡寫如下代碼:
//只讓這個頁面轉動 - (BOOL)shouldAutorotate { return YES; } - (UIInterfaceOrientationMask)supportedInterfaceOrientations { if (yVideoPlayerView.canOrientationChange == YES) { //剛進入頁面是豎屏 return UIInterfaceOrientationMaskAllButUpsideDown; } return UIInterfaceOrientationMaskPortrait; }