SGPlayer - A powerful media player framework for iOS, macOS, and tvOS. Support 360° panorama video, VR video. RTMP streaming.
14561 단어 iOSMacOSXObjective-CrtmpVR
View SGPlayer on GitHub
Principle
SGPlayer
Features
Build Instructions (Choose one of the way)
Method 1. Using build script
// iOS
git clone https://github.com/libobjc/SGPlayer.git
cd SGPlayer
sh compile-build.sh iOS
// macOS
git clone https://github.com/libobjc/SGPlayer.git
cd SGPlayer
sh compile-build.sh macOS
// tvOS
git clone https://github.com/libobjc/SGPlayer.git
cd SGPlayer
sh compile-build.sh tvOS
Method 2. Manually build
git clone [email protected]:libobjc/SGPlayer.git
cd SGPlayer
git submodule update --init --recursive
/SGPlayer/Classes/Core/SGFFPlayer/ffmpeg/lib-iOS // iOS
/SGPlayer/Classes/Core/SGFFPlayer/ffmpeg/lib-macOS // macOS
/SGPlayer/Classes/Core/SGFFPlayer/ffmpeg/lib-tvOS // tvOS
check build results
Usage
Dependencies
// iOS
- SGPlayer.framework
- SGPlatform.framework Optional
- CoreMedia.framework
- AudioToolBox.framework
- VideoToolBox.framework
- libiconv.tbd
- libbz2.tbd
- libz.tbd
// macOS
- SGPlayer.framework
- SGPlatform.framework Optional
- CoreMedia.framework
- AudioToolBox.framework
- VideoToolBox.framework
- VideoDecodeAcceleration.framework
- libiconv.tbd
- libbz2.tbd
- libz.tbd
- libizma.tbd
Basic video playback
self.player = [SGPlayer player];
// register callback handle.
[self.player registerPlayerNotificationTarget:self stateAction:@selector(stateAction:) progressAction:@selector(progressAction:) playableAction:@selector(playableAction:) errorAction:@selector(errorAction:)];
// display view tap action.
[self.player setViewTapAction:^(SGPlayer * _Nonnull player, SGPLFView * _Nonnull view) {
NSLog(@"player display view did click!");
}];
// playback plane video.
[self.player replaceVideoWithURL:contentURL]; // 方式1
[self.player replaceVideoWithURL:contentURL videoType:SGVideoTypeNormal]; // 方式2
// playback 360° panorama video.
[self.player replaceVideoWithURL:contentURL videoType:SGVideoTypeVR];
// start playing
[self.player play];
고급 설정
// selected playback core.
self.player.decoder = [SGPlayerDecoder defaultDecoder]; // default config,Together with AVPlayer and FFmpeg.
self.player.decoder = [SGPlayerDecoder AVPlayerDecoder]; // only use AVPlayer
self.player.decoder = [SGPlayerDecoder FFmpegDecoder]; // only use FFmpeg
// set the specified format playback core.
self.player.decoder.decodeTypeForMPEG4 = SGDecoderTypeFFmpeg; // use FFmoeg play mp4 files.
// open FFmpeg hardware accelerate.
self.player.decoder.hardwareAccelerateEnableForFFmpeg = YES;
// enter cardboard mode
self.player.displayMode = SGDisplayModeBox;
// set background mode.
// if allow background mode, you should open 'Background Modes' and check 'Audio' option, and set AVAudioSession Category to AVAudioSessionCategoryPlayback
self.player.backgroundMode = SGPlayerBackgroundModeAutoPlayAndPause; // auto play and pause.
self.player.backgroundMode = SGPlayerBackgroundModeContinue; // continue.
Screenshots
iOS
macOS
커뮤니케이션
Reference
이 문제에 관하여(SGPlayer - A powerful media player framework for iOS, macOS, and tvOS. Support 360° panorama video, VR video. RTMP streaming.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/libobjc/items/a7eeb1fbe408df6763ec텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)