Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

iOS VideoPlayer MediaPlayer video player media player 短视频播放器 可接入 ijkplayer aliplayer alivodplayer plplayer

License

NotificationsYou must be signed in to change notification settings

changsanjiang/SJVideoPlayer

Repository files navigation

readme

Build StatusVersionPlatformLicense

安装

pod'SJVideoPlayer'

项目配置旋转

  • step 1:前往Targets ->General ->Device Orientation -> 选择Portrait;

  • step 2:前往AppDelegate, 导入头文件#import "SJRotationManager.h", 在application:supportedInterfaceOrientationsForWindow:中返回[SJRotationManager supportedInterfaceOrientationsForWindow:window];

#import"SJRotationManager.h"@implementationAppDelegate- (UIInterfaceOrientationMask)application:(UIApplication *)applicationsupportedInterfaceOrientationsForWindow:(UIWindow *)window {return [SJRotationManagersupportedInterfaceOrientationsForWindow:window];}@end/// swift/// class AppDelegate: UIResponder, UIApplicationDelegate {///     func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> /// UIInterfaceOrientationMask {///         return window.supportedInterfaceOrientations(window)///     }/// }
  • step 3:以下分类在项目中随便找个地方, 复制进去即可;
@implementationUIViewController (RotationConfiguration)- (BOOL)shouldAutorotate {returnNO;}- (UIInterfaceOrientationMask)supportedInterfaceOrientations {return UIInterfaceOrientationMaskPortrait;}@end@implementationUITabBarController (RotationConfiguration)- (UIViewController *)sj_topViewController {if ( self.selectedIndex ==NSNotFound )return self.viewControllers.firstObject;return self.selectedViewController;}- (BOOL)shouldAutorotate {return [[selfsj_topViewController]shouldAutorotate];}- (UIInterfaceOrientationMask)supportedInterfaceOrientations {return [[selfsj_topViewController]supportedInterfaceOrientations];}- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {return [[selfsj_topViewController]preferredInterfaceOrientationForPresentation];}@end@implementationUINavigationController (RotationConfiguration)- (BOOL)shouldAutorotate {return self.topViewController.shouldAutorotate;}- (UIInterfaceOrientationMask)supportedInterfaceOrientations {return self.topViewController.supportedInterfaceOrientations;}- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {return self.topViewController.preferredInterfaceOrientationForPresentation;}- (nullable UIViewController *)childViewControllerForStatusBarStyle {return self.topViewController;}- (nullable UIViewController *)childViewControllerForStatusBarHidden {return self.topViewController;}@end
  • setup 4: iOS 13.0 之后, 需在自己的vc中实现shouldAutorotate, 并返回NO.
@interfaceYourPlayerViewController ()@property (nonatomic,strong) SJVideoPlayer *player;@end@implementationYourPlayerViewController - (BOOL)shouldAutorotate {returnNO;} - (void)viewDidAppear:(BOOL)animated {    [superviewDidAppear:animated];    [_playervc_viewDidAppear]; }- (void)viewWillDisappear:(BOOL)animated {    [superviewWillDisappear:animated];     [_playervc_viewWillDisappear];}- (void)viewDidDisappear:(BOOL)animated {    [superviewDidDisappear:animated];    [_playervc_viewDidDisappear]; }@end

快速开始

  1. 导入头文件
#import<SJVideoPlayer/SJVideoPlayer.h>
  1. 添加player属性
@interfaceViewController ()@property (nonatomic,strong,readonly) SJVideoPlayer *player;@end
  1. 创建player对象
- (void)viewDidLoad {    [superviewDidLoad];        _player = SJVideoPlayer.player;    [self.viewaddSubview:_player.view];    [_player.viewmas_makeConstraints:^(MASConstraintMaker *make) {if (@available(iOS11.0, *)) {            make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop);        }else {            make.top.offset(20);        }        make.left.right.offset(0);        make.height.equalTo(self.player.view.mas_width).multipliedBy(9/16.0);    }];}- (BOOL)shouldAutorotate {returnNO;}- (void)viewDidAppear:(BOOL)animated {    [superviewDidAppear:animated];    [_playervc_viewDidAppear];}- (void)viewWillDisappear:(BOOL)animated {    [superviewWillDisappear:animated];    [_playervc_viewWillDisappear];}- (void)viewDidDisappear:(BOOL)animated {    [superviewDidDisappear:animated];    [_playervc_viewDidDisappear];}
  1. 通过URL进行播放
SJVideoPlayerURLAsset *asset = [SJVideoPlayerURLAsset.allocinitWithURL:_media.URL];_player.URLAsset = asset;

Author

Email:changsanjiang@gmail.com

QQGroup: 610197491 (iOS 开发 2)

QQGroup: 930508201 (iOS 开发)(这个群满员了, 请加2群吧)

赞助

如果对您有所帮助,欢迎您的赞赏

About

iOS VideoPlayer MediaPlayer video player media player 短视频播放器 可接入 ijkplayer aliplayer alivodplayer plplayer

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors6

Languages


[8]ページ先頭

©2009-2025 Movatter.jp