Skip to content

iOS open source framework to create live broadcasts and video streams on YouTube with YouTube Data API v3

License

Notifications You must be signed in to change notification settings

SKrotkih/YTLiveStreaming

Repository files navigation

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.

Install

  • Download or clone the repository.

  • Select root folder

  • Launch pod install

Prepare and launch the example

  • 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