正在准备 1.1.0 迭代版本,重点是添加一些功能和提升稳定性。目前确定会做的更新如下:
- 倍速播放。
- 支持内嵌字幕。
- 仅播放画面或声音。
- 性能优化。
如果你有需求建议请拼命提 issue。我会考虑纳入开发计划中。
中文介绍 | Principle(原理详解) | Video Download(视频下载)
- SGPlayer is a powerful media player framework for iOS, macOS, and tvOS. based on AVPlayer and FFmpeg. Support 360° panorama video, VR video. RTMP streaming.
- 360° panorama video.
- Gestures and sensors control vr video.
- distortion correction in cardboard mode.
- Support iOS, macOS, and tvOS.
- H.264 hardware accelerator (VideoToolBox).
- RTMP, RTSP streamings.
- Background playback mode.
- Selected audio track.
- Adjust the volume.
- Capture video artwork.
- Bitcode support.
- Simplest callback handle.
// 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
- Step 1 - clone and init submodule.
git clone https://github.com/libobjc/SGPlayer.git
cd SGPlayer
git submodule update --init --recursive
- Step 2 - build FFmpeg and add libs to the corresponding directory.
/SGPlayer/Classes/Core/SGFFPlayer/ffmpeg/lib-iOS // iOS
/SGPlayer/Classes/Core/SGFFPlayer/ffmpeg/lib-macOS // macOS
/SGPlayer/Classes/Core/SGFFPlayer/ffmpeg/lib-tvOS // tvOS
- more examples in the demo applications.
// 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
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.
- Plane video
- 360° panorama video
- Cardboard mode
- Plane video
- 360° panorama video
- Email : libobjc@gmail.com
- Twitter : CoderSingle
- Weibo : 程序员Single
- QQ Group : 616349536