Giter Club home page Giter Club logo

sgplayer's Introduction

Important Notice

SGPlayer will be redesigned. Version 2.0 will be released in the spring of 2019.

(Logo)

Build Status Platform Support

中文介绍 | Principle | Video Download

SGPlayer

  • 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.

Features

  • 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.

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

  • 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

check build results

ffmpeg-libs

Usage

  • more examples in the demo applications.

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];

Advanced settings

// 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

  • Plane video

ios-i-see-fire

  • 360° panorama video

ios-google-vr

  • Cardboard mode

ios-google-vr-box

macOS

  • Plane video

mac-i-see-fire

  • 360° panorama video

mac-google-vr

Communication

Developed by Single

sgplayer's People

Contributors

libobjc avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.