Giter Site home page Giter Site logo

hansemannn / facebook-live-ios Goto Github PK

View Code? Open in Web Editor NEW
55.0 8.0 21.0 1.34 MB

📺 A Swift utility "FBSDKLiveVideo" to stream Facebook Live videos on iOS

License: MIT License

Ruby 0.75% Objective-C 1.46% Swift 97.79%
facebook-sdk ios facebook-login sample

facebook-live-ios's Introduction

 Facebook Live iOS

A custom Swift utility "FBSDKLiveVideo" to stream Facebook Live videos on iOS.

App Store

Example

The following example would create a full-screen live video preview that is started when the user taps the trigger button linked in your Storyboard.

class ViewController: UIViewController {
    
    var liveVideo: FBSDKLiveVideo!

    override func viewDidLoad() {
        super.viewDidLoad()
      
        // Create the live video service
        liveVideo = FBSDKLiveVideo(
            delegate: self,
            previewSize: self.view.bounds,
            videoSize: CGSize(width: 1280, height: 720)
        )
        
        // Optional: Configure the live-video (see the source for all options)
        liveVideo.privacy = .me // or .friends, .friendsOfFriends, .custom
        liveVideo.audience = "me" // or your user-id, page-id, event-id, group-id, ...
        
        // Optional: Add the preview view of the stream to your container view.
        myView.addSubView(liveVideo.preview)
    }
    
    @IBAction func recordButtonTapped() {
        liveVideo.start()
    }    

    @IBAction func stopButtonTapped() {
        liveVideo.stop();
    }

    @IBAction func adBreakButtonTapped() {
        liveVideo.adBreakStartNow = true
        liveVido.update();
    }

    @IBAction func deleteButtonTapped() {
        liveVido.delete();
    }
}

extension ViewController: FBSDKLiveVideoDelegate {
    func liveVideo(_ liveVideo: FBSDKLiveVideo, didStartWith session: FBSDKLiveVideoSession) {
        // Live video started
    }

    func liveVideo(_ liveVideo: FBSDKLiveVideo, didStopWith session: FBSDKLiveVideoSession) {
        // Live video ended
    }

    func liveVideo(_ liveVideo: FBSDKLiveVideo, didErrorWith: Error) {
        // Live video errored
    }

    func liveVideo(_ liveVideo: FBSDKLiveVideo, didChange sessionState: FBSDKLiveVideoSessionState) {
        // Live video changed session state
        // One of: .none, .previewStarted, .starting, .started, .ended, .error
    }

    func liveVideo(_ liveVideo: FBSDKLiveVideo, didAdd cameraSource: FBSDKLiveVideoSession) {
        // New camera source added to the stream
    }

    func liveVideo(_ liveVideo: FBSDKLiveVideo, didUpdate session: FBSDKLiveVideoSession) {
        // Live video was updated through update()
    }

    func liveVideo(_ liveVideo: FBSDKLiveVideo, didDelete session: FBSDKLiveVideoSession) {
        // Live video was deleted through delete()
    }
}

Build

  • Run pod install to install the required dependencies (Facebook SDK + VideoCore)
  • Open the facebook-live-ios-sample.xcworkspace file in Xcode
  • Change the app-id inside the Info.plist to match your app. Ensure to configure the App-ID correctly
  • Run the project on your iOS device! By default, it will only start a live-stream to your private audience ("Only me")

License

MIT - Try it out, modify it, use it!

Author

Hans Knöchel (@hansemannnn)

Contributions

Code contributions are greatly appreciated, please submit a new Pull Request!

facebook-live-ios's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

facebook-live-ios's Issues

Live videos in portrait during the live appear square sized on the mobile feed

I've changed the videoSize to 720, 1280 so that I can stream portrait. When I go live, the videos appear square sized on my other device's mobile feed on Facebook, but turn normal when I end the live and refresh the feed. Also during the live and tapping the video to watch on the another mobile device, the video doesn't take up the whole screen like it would when streaming from the Facebook app. Any ideas appreciated. I've already experimented changing the VCAspectMode and useInterfaceOrientation.

Thanks!

Content Tags

Hi, I have tried using an array of strings as the content type eg: ["cats","boats"] however it is giving an error when doing the POST request. What is the correct format for using the content_tags option?

Video source

Hi! Is it possible to set an alternative video source to stream? I have an incoming RTP stream that is accessible via CVImageBuffer and it would be great to set the stream to show this.

Thanks

Can not sharing video to public

Hi there.
I really really interesting with the project. I also saw the code but it only accepted sharing a video for "Only me" mode.
self.liveVideo.privacy = .me
self.liveVideo.audience = "me" // or your user-id, page-id, event-id, group-id, ...
Now I also changed code like
self.liveVideo.privacy = .friends
self.liveVideo.audience = "FRIEND" // or your user-id, page-id, event-id, group-id, ...
But it can not record video,then.
Could you suggest me another way to record and public video with "Public" or "Friends" mode?
Thanks.

Embeddable ressources

Hi,
Is it possible to embed any additional materials (images, text, ... ) on the camera source preview, that could also be viewable by users over the live stream on facebook feed ?
Thanks for your help,
j.

'func_trigonometric.inl' file not found in swift 5

when i build sample project there is getting error file not found.
/Users/mobmaxime112/Downloads/facebook-live-ios-master/Pods/Headers/Private/glm/core/func_trigonometric.hpp:199:10: 'func_trigonometric.inl' file not found
thank you in advance

How to stream page and group, event live video using your project?

Hello, Hans!

Thanks!

I am a man that love your code style.
Your project is great one.
I didn't still discovered FB streaming ios app such as your project.

Your project is working well.

I appreciate your project and professional skills.
I have many learned from you how to stream live video in facebook.

Very nice project!!!

And now, I have one question.

I have already implemented only user's timeline live video streaming.
now, I have to implement pages and group, event live video streaming function also.

In your project, you wrote that have to replace page id or group id, event id in "audience" parameter of FBLiveVideo class.

So, my problem is how to get page id and group id and event id.

I have googled many times to find any solution(honestly full two days).
But, I have not still found any solution about my problem.
screenshot_5

Would you please help me more?

Thanks for your code and professional skills.
Best regards!
From Gojko Maric

I can't install 'VideoCore' framework using cocoapods in swift 4.0

Hello.

I have downloaded your project in git.
Then opened your project, but, pod file was damaged when I open downloaded project.

So I have removed pod history(podfile, podlock, .xcworkspace file) and then I have created new podfile in your project.

Then opened podfile and pasted this -
pod 'FBSDKShareKit'
pod 'FBSDKLoginKit'
pod 'VideoCore', '~>0.3.1'

After install pod, I have run project.
But, I have got errors.

"Cannot define or redeclare 'H264Encode' here because namespace 'iOS' does not enclose namespace 'H264Encode'" in H264Encode.mm file.

How can I fix it?

Best regards!
Gojko Maric

Text/Image Captions in Live Stream

Great starter app for live streaming, thank you!
I'd like to request a feature that will display text and images in a live stream for captioning. Or an idea of how to implement this. I've done this for simple video recordings, but have no clue how to achieve this in a live stream. I'm thinking it should be similar right?

Live streaming don't works now

Hello

I have implemented your project.

I have passed all Facebook permissions(publish_videos, live_video api)

and I have run project.

app is working now without any error.

when I click start and stop button, I am getting event from "FBLiveVideoDelegate" methods.

but, don't stream live video to my facebook timeline.

What did I miss?

Is there anyway to solve this issue in your project?

Hi,

I have checked your project carefully again.
Then I realized your purpose.

So I have reinstall cocoapods correctly within your pods file.

then I have got this error.
screenshot_6

I think you can fix this error in a short time.

Looking forward for your response.

Best regards.
Gojko Maric

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.