Swiftpack.co - pbj-apps/Live-ios-sdk as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by pbj-apps.
pbj-apps/Live-ios-sdk 0.6.2
Stream your PBJ.live content from your iOS App.
⭐️ 7
🕓 1 year ago
iOS
.package(url: "https://github.com/pbj-apps/Live-ios-sdk.git", from: "0.6.2")

Live Player

Live Platform: iOS 13+ Language: Swift 5 Swift Package Manager compatible Build status GitHub tag

Stream your Live content from your iOS App.

Introduction

The Live iOS SDK enables you to display your Live content inside your iOS App. The live SDK package is separated in two distinct targets: Live which contains all the "core" code and LiveUI containing UI elements.

Installation

In Xcode, select File > Swift packages > Add Package Dependency
and enter Live SDK github url below:

https://github.com/pbj-apps/Live-ios-sdk

Initialization

You need to initialize the Live SDK with your credentials on App start.
A good place to do this is typically the AppDelegate.

import Live

// [...]
let live = LiveSDK.initialize(
   apiKey: "YOUR_API_KEY",
   environment: .dev,
   logLevels: .debug)
  • environment is optional and defaults to .prod.
  • logLevels is also optional and defaults to .off.

The whole Live api is accessed via this live object which exposes a classic Combine api returning AnyPublisher<Result, Error>

Authentication

Before querying any data, you need to authenticate the SDK. This process is asynchonous.

live.authenticateAsGuest()
   .sink { 
      // SDK is now authenticated \o/
   }
   .store(in: &cancellables)

Api

VoD

Categories

Fetch all VoD Categories

live.fetchVodCategories().sink { categories in 
   // categories
}
.store(in: &cancellables)

Fetch a specific VoD Category

live.fetch(category: category).sink { category in 
   // category
}
.store(in: &cancellables)

Playlists

Fetch all playlists

live.fetchVodPlaylists().sink { playlists in 
   // playlists
}
.store(in: &cancellables)

Fetch a specific playlist

live.fetch(playlist: playlist).sink { playlist in 
   // playlist
}
.store(in: &cancellables)

Videos

Fetch all VoD Videos

live.fetchVodVideos().sink { videos in 
   // videos
}
.store(in: &cancellables)

Fetch a specific VoD Video

live.fetch(video: vodVideo).sink { video in 
  // video
}
.store(in: &cancellables)

Search

Search Vod Videos only

live.searchVodVideos(query: query).sink { videos in 
   // videos
}
.store(in: &cancellables)

Search Vod Videos & Playlists

live.searchVod(query: query).sink { vodItems in 
   // vodItems (VodVideo & VodPlaylist)
}
.store(in: &cancellables)

Live

Episodes

Fetch all episodes

live.fetchEpisodes().sink { episodes in 
   // episodes
}
.store(in: &cancellables)

Fetch a specific episode

live.fetch(episode: Episode).sink { episode in 
   // episode
}
.store(in: &cancellables)

UI Components

In order to have access to UI elements, you will need to import LiveUI.

UI components provided are 100% build with SwiftUI. For apps that haven't made the switch yet, we also provide a UIKit compatible api.

Live Player

SwiftUI

LivePlayer(episode: episode, close: { })

UIKIt

let livePlayerVC = LivePlayerViewController(episode: episode)
livePlayerVC.delegate = self
present(livePlayerVC, animated: true, completion: nil)

Here showId is optional and without it, it would play the first live stream found.

VOD Player

SwiftUI

VodPlayer(url: vodUrl, close: {})

UIKit

let vodPlayerVC = VodPlayerViewController(url: vodUrl)
vodPlayerVC.delegate = self
present(vodPlayerVC, animated: true, completion: nil)

Example App

Checkout the example App provided in this repository to see a typical integration. With the test app, you can input your Organization api key and battle test your own environment.

Got a question? Found an issue?

Create a github issue and we'll help you from there ❤️

GitHub

link
Stars: 7
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

0.6.2
1 year ago

Add product external id

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics