Skip to content

Commit

Permalink
Merge pull request #1 from StreamAMG/feature/documentation
Browse files Browse the repository at this point in the history
Feature/documentation
  • Loading branch information
francodriansetti authored Feb 28, 2024
2 parents b9456e0 + 82386f3 commit a98a50f
Show file tree
Hide file tree
Showing 2,701 changed files with 3,908 additions and 51 deletions.
52 changes: 52 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"object": {
"pins": [
{
"package": "BitmovinAnalytics",
"repositoryURL": "https://github.com/bitmovin/bitmovin-analytics-collector-ios.git",
"state": {
"branch": null,
"revision": "3feebb1db5f6bc2d3ad0b7241f3baea523e9ab9e",
"version": "3.6.0"
}
},
{
"package": "BitmovinPlayer",
"repositoryURL": "https://github.com/bitmovin/player-ios.git",
"state": {
"branch": null,
"revision": "31ed8a5fb931bd600c5e1ca6d19c17d77762b56b",
"version": "3.56.1"
}
},
{
"package": "BitmovinPlayerCore",
"repositoryURL": "https://github.com/bitmovin/player-ios-core.git",
"state": {
"branch": null,
"revision": "7a2742ff415a7423fd62c0ed23fe1c9ca8fcaa9f",
"version": "3.56.1"
}
},
{
"package": "SwiftDocCPlugin",
"repositoryURL": "https://github.com/apple/swift-docc-plugin",
"state": {
"branch": null,
"revision": "26ac5758409154cc448d7ab82389c520fa8a8247",
"version": "1.3.0"
}
},
{
"package": "SymbolKit",
"repositoryURL": "https://github.com/apple/swift-docc-symbolkit",
"state": {
"branch": null,
"revision": "b45d1f2ed151d057b54504d653e0da5552844e34",
"version": "1.0.0"
}
}
]
},
"version": 1
}
6 changes: 5 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ let package = Package(
// BitmovinPlayer
.package(name: "BitmovinPlayer",
url: "https://github.com/bitmovin/player-ios.git",
.exact("3.56.1"))
.exact("3.56.1")),

// other dependencies
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0")

],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
Expand Down
32 changes: 0 additions & 32 deletions Sources/PlaybackSDK/Article.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// InitializeSdkExample.swift
//
//
// Created by Franco Driansetti on 27/02/2024.
//

import PlaybackSDK

PlaybackSDKManager.shared.initialize(apiKey: "YOUR_API_KEY") { result in
switch result {
case .success:
print("Playback SDK initialized successfully.")
case .failure(let error):
print("Error initializing Playback SDK: \(error)")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// InstallPlayerPluginTutorial.swift
//
//
// Created by Franco Driansetti on 27/02/2024.
//

import Foundation

PlayBackSDKManager.shared.initialize(apiKey: settingsManager.apiKey, baseURL: settingsManager.baseURL) { result in
switch result {
case .success(let license):
print("SDK initialized with license: \(license)")

// Add player plugin
let bitmovinPlugin = BitmovinPlayerPlugin()
VideoPlayerPluginManager.shared.registerPlugin(bitmovinPlugin)

case .failure(let error):
print("SDK initialization failed with error: \(error)")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// LoadHlsStreamTutorial.swift
//
//
// Created by Franco Driansetti on 27/02/2024.
//

import Foundation

import SwiftUI

internal struct ContentView: View {
let entryId = "YOUR_ENTRY_ID"
let authorizationToken = "YOUR_AUTHORIZATION_TOKEN" // optional


var body: some View {
PlaybackUIView(entryId: entryId, authorizationToken: authorizationToken)
}
}

struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// LoadPlayerViewTutorial.swift
//
//
// Created by Franco Driansetti on 27/02/2024.
//

import Foundation

PlayBackSDKManager.shared.loadPlayer(entryID: settingsManager.entryId, authorizationToken: settingsManager.authorizationToken, onError: { error in
// Handle the error here
switch error {
case .apiError(let statusCode, _):
print("\(statusCode)")
default:
print("Error loading HLS stream in PlaybackUIView: \(error.localizedDescription)")
}
})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
@Tutorial(time: 30) {
@Intro(title: "Playback SDK Overview") {
Playback SDK simplifies integrating video playback functionalities into OTT applications. It provides a unified interface for interacting with video APIs and managing playback logic.

**Key Features:**

- **Abstraction:** Hides the complexities of underlying video APIs, allowing you to focus on the core playback experience.
- **Flexibility:** Supports different video providers and allows the creation of custom playback plugins for extended functionalities.
- **Error Handling:** Provides mechanisms to handle potential issues during playback and notify your application.
}

@Section(title: "Video Player Plugins (Optional)") {
@ContentAndMedia {
The Playback SDK supports extending functionalities through custom video player plugins. These plugins can provide extended functionalities or integrate with third-party video players. Refer to the full source code for details on creating custom plugins.

```swift
// Implement your custom player plugin conforming to VideoPlayerPlugin protocol

// Register your custom plugin with the manager
let pluginManager = VideoPlayerPluginManager.shared
pluginManager.registerPlugin(YourCustomPlayerPlugin())
// Use the selected plugin for playback
pluginManager.selectedPlugin?.play()
```

@Image(source: "custom_plugin.png", alt: "Custom Video Player Plugin")
}

@Steps {
@Step {
**Step 1:** Implement your custom player plugin conforming to the `VideoPlayerPlugin` protocol.

@Image(source: "custom_plugin_step1.png", alt: "Implement Custom Plugin")
}

@Step {
**Step 2:** Register your custom plugin with the manager and use the selected plugin for playback.

@Image(source: "custom_plugin_step2.png", alt: "Register Custom Plugin")
@Code(name: "RegisterAndUsePlugin", file: RegisterAndUsePlugin.swift)
}
}
}

@Section(title: "Error Handling") {
@ContentAndMedia {
The library propagates errors through completion handlers. You can handle these errors to provide appropriate feedback to the user.

**Example:**

Swift

```
PlaybackSDKManager.shared.initialize(apiKey: "YOUR_API_KEY") { result in
switch result {
case .success:
print("Playback SDK initialized successfully.")

let entryId = "YOUR_ENTRY_ID"
let authorizationToken = "YOUR_AUTHORIZATION_TOKEN" // optional

PlaybackUIView(entryId: entryId, authorizationToken: authorizationToken)
case .failure(let error):
print("Error initializing Playback SDK: \(error)")
}
}
```

@Image(source: "error_handling.png", alt: "Error Handling")
}
}
}
120 changes: 120 additions & 0 deletions Sources/PlaybackSDK/Documentation.docc/Tutorial/GetStarted.tutorial
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
@Tutorial(time: 30) {
@Intro(title: "Playback SDK Overview") {
Playback SDK simplifies integrating video playback functionalities into OTT applications. It provides a unified interface for interacting with video APIs and managing playback logic.

**Key Features:**

- **Abstraction:** Hides the complexities of underlying video APIs, allowing you to focus on the core playback experience.
- **Flexibility:** Supports different video providers and allows the creation of custom playback plugins for extended functionalities.
- **Error Handling:** Provides mechanisms to handle potential issues during playback and notify your application.
}

@Section(title: "Installation") {
@ContentAndMedia {
To install the Playback SDK, follow these steps:

1. Add the Playback SDK dependency to your project using Swift Package Manager.

Swift

```
dependencies: [
.package(url: "https://github.com/your-organization/playback-sdk.git", .branch("master"))
]
```

2. Import the `PlaybackSDK` module in your Swift files.

Swift

```
import PlaybackSDK
```
}

@Steps {
@Step {
**Step 1:** Initialize the Playback SDK by providing your API key.

@Code(name: "InitializeSdkExample", file: InitializeSdkExample.swift)
}

@Step {
**Step 2:** Load HLS Stream by providing the entry ID and optional authorization token.

@Code(name: "LoadHlsStreamTutorial", file: LoadHlsStreamTutorial.swift)
}

@Step {
**Step 3:** Add player plugin. Note: This should be done in the AppDelegate.
@Code(name: "InstallPlayerPluginTutorial", file: InstallPlayerPluginTutorial.swift)
}

@Step {
**Step 4:** Load the player view in your player view and handle errors.
@Code(name: "LoadPlayerViewTutorial", file: LoadPlayerViewTutorial.swift)
}
}
}

@Section(title: "Video Player Plugins (Optional)") {
@ContentAndMedia {
The Playback SDK supports extending functionalities through custom video player plugins. These plugins can provide extended functionalities or integrate with third-party video players. Refer to the full source code for details on creating custom plugins.

```swift
// Implement your custom player plugin conforming to VideoPlayerPlugin protocol

// Register your custom plugin with the manager
let pluginManager = VideoPlayerPluginManager.shared
pluginManager.registerPlugin(YourCustomPlayerPlugin())
// Use the selected plugin for playback
pluginManager.selectedPlugin?.play()
```

@Image(source: "custom_plugin.png", alt: "Custom Video Player Plugin")
}

@Steps {
@Step {
**Step 1:** Implement your custom player plugin conforming to the `VideoPlayerPlugin` protocol.

@Image(source: "custom_plugin_step1.png", alt: "Implement Custom Plugin")
}

@Step {
**Step 2:** Register your custom plugin with the manager and use the selected plugin for playback.

@Image(source: "custom_plugin_step2.png", alt: "Register Custom Plugin")
@Code(name: "RegisterAndUsePlugin", file: RegisterAndUsePlugin.swift)
}
}
}

@Section(title: "Error Handling") {
@ContentAndMedia {
The library propagates errors through completion handlers. You can handle these errors to provide appropriate feedback to the user.

**Example:**

Swift

```
PlaybackSDKManager.shared.initialize(apiKey: "YOUR_API_KEY") { result in
switch result {
case .success:
print("Playback SDK initialized successfully.")

let entryId = "YOUR_ENTRY_ID"
let authorizationToken = "YOUR_AUTHORIZATION_TOKEN" // optional

PlaybackUIView(entryId: entryId, authorizationToken: authorizationToken)
case .failure(let error):
print("Error initializing Playback SDK: \(error)")
}
}
```

@Image(source: "error_handling.png", alt: "Error Handling")
}
}
}
Loading

0 comments on commit a98a50f

Please sign in to comment.