{"id":13483925,"url":"https://github.com/changsanjiang/SJVideoPlayer","last_synced_at":"2025-03-27T15:30:49.323Z","repository":{"id":37663852,"uuid":"100693284","full_name":"changsanjiang/SJVideoPlayer","owner":"changsanjiang","description":"iOS VideoPlayer MediaPlayer video player media player 短视频播放器 可接入 ijkplayer aliplayer alivodplayer plplayer","archived":false,"fork":false,"pushed_at":"2022-12-10T08:57:54.000Z","size":377720,"stargazers_count":2456,"open_issues_count":178,"forks_count":476,"subscribers_count":39,"default_branch":"master","last_synced_at":"2024-10-24T17:50:29.215Z","etag":null,"topics":["avplayer","generate-gif","player","video-player","videoplayer"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/changsanjiang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-18T08:56:30.000Z","updated_at":"2024-10-23T01:29:31.000Z","dependencies_parsed_at":"2022-07-13T15:59:46.045Z","dependency_job_id":null,"html_url":"https://github.com/changsanjiang/SJVideoPlayer","commit_stats":null,"previous_names":[],"tags_count":174,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/changsanjiang%2FSJVideoPlayer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/changsanjiang%2FSJVideoPlayer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/changsanjiang%2FSJVideoPlayer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/changsanjiang%2FSJVideoPlayer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/changsanjiang","download_url":"https://codeload.github.com/changsanjiang/SJVideoPlayer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245480176,"owners_count":20622265,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["avplayer","generate-gif","player","video-player","videoplayer"],"created_at":"2024-07-31T17:01:16.917Z","updated_at":"2025-03-27T15:30:44.307Z","avatar_url":"https://github.com/changsanjiang.png","language":"Objective-C","funding_links":[],"categories":["Media","HarmonyOS","OOM-Leaks-Crash","Objective-C"],"sub_categories":["Windows Manager","Player"],"readme":"![readme](https://user-images.githubusercontent.com/37614260/43947531-922a0712-9cb2-11e8-8f8d-4823a21308d3.png)\n\n[![Build Status](https://travis-ci.org/changsanjiang/SJVideoPlayer.svg?branch=master)](https://travis-ci.org/changsanjiang/SJVideoPlayer)\n[![Version](https://img.shields.io/cocoapods/v/SJVideoPlayer.svg?style=flat)](https://cocoapods.org/pods/SJVideoPlayer)\n[![Platform](https://img.shields.io/badge/platform-iOS-blue.svg)](https://github.com/changsanjiang)\n[![License](https://img.shields.io/github/license/changsanjiang/SJVideoPlayer.svg)](https://github.com/changsanjiang/SJVideoPlayer/blob/master/LICENSE.md)\n\n## [前往文档](https://github.com/changsanjiang/SJVideoPlayer/wiki)\n\n# 安装\n \n```ruby\npod 'SJVideoPlayer'\n```\n\n# 项目配置旋转\n\n- step 1:\n前往`Targets` -\u003e `General` -\u003e `Device Orientation` -\u003e 选择 `Portrait`;\n![](https://user-images.githubusercontent.com/25744224/101907041-ebdb2a00-3bf4-11eb-8d90-6faf1f9a73c8.png)\n\n- step 2:\n前往`AppDelegate`, 导入头文件`#import \"SJRotationManager.h\"`, 在`application:supportedInterfaceOrientationsForWindow:`中返回`[SJRotationManager supportedInterfaceOrientationsForWindow:window]`;\n```Objective-C\n#import \"SJRotationManager.h\"\n\n@implementation AppDelegate\n- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {\n    return [SJRotationManager supportedInterfaceOrientationsForWindow:window];\n}\n@end\n\n/// swift\n/// class AppDelegate: UIResponder, UIApplicationDelegate {\n///     func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -\u003e /// UIInterfaceOrientationMask {\n///         return window.supportedInterfaceOrientations(window)\n///     }\n/// }\n```\n\n- step 3:\n以下分类在项目中随便找个地方, 复制进去即可;\n```Objective-C\n@implementation UIViewController (RotationConfiguration)\n- (BOOL)shouldAutorotate { \n    return NO;\n}\n\n- (UIInterfaceOrientationMask)supportedInterfaceOrientations {\n    return UIInterfaceOrientationMaskPortrait;\n}\n@end\n\n\n@implementation UITabBarController (RotationConfiguration)\n- (UIViewController *)sj_topViewController {\n    if ( self.selectedIndex == NSNotFound )\n        return self.viewControllers.firstObject;\n    return self.selectedViewController;\n}\n\n- (BOOL)shouldAutorotate {\n    return [[self sj_topViewController] shouldAutorotate];\n}\n\n- (UIInterfaceOrientationMask)supportedInterfaceOrientations {\n    return [[self sj_topViewController] supportedInterfaceOrientations];\n}\n\n- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {\n    return [[self sj_topViewController] preferredInterfaceOrientationForPresentation];\n}\n@end\n\n@implementation UINavigationController (RotationConfiguration)\n- (BOOL)shouldAutorotate {\n    return self.topViewController.shouldAutorotate;\n}\n\n- (UIInterfaceOrientationMask)supportedInterfaceOrientations {\n    return self.topViewController.supportedInterfaceOrientations;\n}\n\n- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {\n    return self.topViewController.preferredInterfaceOrientationForPresentation;\n}\n\n- (nullable UIViewController *)childViewControllerForStatusBarStyle {\n    return self.topViewController;\n}\n\n- (nullable UIViewController *)childViewControllerForStatusBarHidden {\n    return self.topViewController;\n}\n@end\n``` \n\n- setup 4: iOS 13.0 之后, 需在自己的vc中实现`shouldAutorotate`, 并返回`NO`.\n```Objective-C\n@interface YourPlayerViewController ()\n@property (nonatomic, strong) SJVideoPlayer *player;\n@end\n\n@implementation YourPlayerViewController \n- (BOOL)shouldAutorotate { \n    return NO;\n} \n\n- (void)viewDidAppear:(BOOL)animated {\n    [super viewDidAppear:animated];\n    [_player vc_viewDidAppear]; \n}\n\n- (void)viewWillDisappear:(BOOL)animated {\n    [super viewWillDisappear:animated]; \n    [_player vc_viewWillDisappear];\n}\n\n- (void)viewDidDisappear:(BOOL)animated {\n    [super viewDidDisappear:animated];\n    [_player vc_viewDidDisappear]; \n}\n@end\n```\n\n# 快速开始\n\n1. 导入头文件\n```Objective-C\n#import \u003cSJVideoPlayer/SJVideoPlayer.h\u003e\n```\n\n2. 添加`player`属性\n```Objective-C\n@interface ViewController ()\n@property (nonatomic, strong, readonly) SJVideoPlayer *player;\n@end\n```\n\n3. 创建`player`对象\n```Objective-C\n- (void)viewDidLoad {\n    [super viewDidLoad];\n    \n    _player = SJVideoPlayer.player;\n    [self.view addSubview:_player.view];\n    [_player.view mas_makeConstraints:^(MASConstraintMaker *make) {\n        if (@available(iOS 11.0, *)) {\n            make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop);\n        } else {\n            make.top.offset(20);\n        }\n        make.left.right.offset(0);\n        make.height.equalTo(self.player.view.mas_width).multipliedBy(9/16.0);\n    }];\n}\n\n- (BOOL)shouldAutorotate {\n    return NO;\n}\n\n- (void)viewDidAppear:(BOOL)animated {\n    [super viewDidAppear:animated];\n    [_player vc_viewDidAppear];\n}\n\n- (void)viewWillDisappear:(BOOL)animated {\n    [super viewWillDisappear:animated];\n    [_player vc_viewWillDisappear];\n}\n\n- (void)viewDidDisappear:(BOOL)animated {\n    [super viewDidDisappear:animated];\n    [_player vc_viewDidDisappear];\n}\n```\n\n4. 通过URL进行播放\n```Objective-C\nSJVideoPlayerURLAsset *asset = [SJVideoPlayerURLAsset.alloc initWithURL:_media.URL];\n_player.URLAsset = asset;\n```\n\n## Author\n\nEmail: changsanjiang@gmail.com\n\nQQGroup: 610197491 (iOS 开发 2)\n\nQQGroup: 930508201 (iOS 开发)(这个群满员了, 请加2群吧)\n\n## 赞助\n如果对您有所帮助，欢迎您的赞赏\n\n\u003cimg src=\"https://github.com/changsanjiang/SJBaseVideoPlayer/blob/master/Project/Project/imgs/thanks_zfb.JPG?raw=true\" width=\"200\"\u003e\n\u003cimg src=\"https://github.com/changsanjiang/SJBaseVideoPlayer/blob/master/Project/Project/imgs/thanks_wechat.JPG?raw=true\" width=\"200\"\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchangsanjiang%2FSJVideoPlayer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchangsanjiang%2FSJVideoPlayer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchangsanjiang%2FSJVideoPlayer/lists"}