cprovatas / YTLiveStreaming

YTLiveStreaming is a framework for creating live broadcasts and video streams on YouTube using the YouTube Live Streaming API (v.3) in Swift 3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

YTLiveStreaming

YTLiveStreaming is a framework for creating live broadcasts and video streams on YouTube using the YouTube Live Streaming API (v.3) in Swift 3

Requirements

  • Xcode 8
  • Swift 3

Introduction

Google API Manager

Note. When you will create an API key, don't check iOS apps in the radio box. Don't worry about yellow warning Key restriction. Take the API key and Client ID. They will be used on the next step.

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.1.0+ is required to build YTLiveStreaming

To integrate YTLiveStreaming into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'YTLiveStreaming'
end

Then, run the following command:

$ pod install

Prepare and launch the example

  • Download or clone the repository.

  • Select Sample folder

  • Launch pod install

  • Open YouTubeLiveVideo.xcworkspace.

  • Put your Cliend ID and API key into plist.info:

Credentials

User guide

import YTLiveStreaming

...

let input: YTLiveStreaming = YTLiveStreaming

...

// Get all events in different arrays of the LiveBroadcastStreamModel type 
input.getAllBroadcasts(){ (upcomingEvents, liveNowEvents, completedEvents) in
   ...
}

// Get events separately:
// Get upcoming events
input.getUpcomingBroadcasts() { upcomingEvents in
   ...
} 

// Get Live now events
input.getLiveNowBroadcasts() ( liveNowEvents in
   ...
} 

// Get Completed events
input.getCompletedBroadcasts() ( completedEvents in
   ...
} 

// Create Broadcast
input.createBroadcast(title, description: description, startTime: startDate, completion: { liveBroadcast in
   if let liveBroadcast = liveBroadcast {
      ...
   }
})

// Update of the existing broadcast: LiveBroadcastStreamModel
input.updateBroadcast(broadcast, completion: { success in
    if success {
       ...
    }      
})

// Start broadcast streaming video
input.startBroadcast(broadcast, delegate: self, completion: { streamName, streamUrl, _ in
   if let streamName = streamName, let streamUrl = streamUrl {
     completion(streamUrl, streamName)
   }
})

// Finish broadcast streaming video
input.completeBroadcast(broadcast, completion: { success in
   if success {
      ...
   }
})

// Delete broadcast video from YouTube
input.deleteBroadcast(id: broadcastId, completion: { success in
    if success {
       ...
    }
})

And some other public methods of the YTLiveStreaming class

Libraries Used

11-11-2016

About

YTLiveStreaming is a framework for creating live broadcasts and video streams on YouTube using the YouTube Live Streaming API (v.3) in Swift 3

License:MIT License


Languages

Language:Swift 97.6%Language:Ruby 1.9%Language:Objective-C 0.6%