Skip to content

Commit

Permalink
Updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
francodriansetti committed Mar 1, 2024
1 parent 8ffb954 commit f2d7b61
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 197 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,18 @@
// Created by Franco Driansetti on 27/02/2024.
//

import Foundation
Swift

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

internal struct ContentView: View {
let entryId = "YOUR_ENTRY_ID"
let authorizationToken = "YOUR_AUTHORIZATION_TOKEN" // optional
2. Import the `PlaybackSDK` module in your Swift files.

Swift

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

struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
```
import PlaybackSDK
```

This file was deleted.

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

import SwiftUI
import PlaybackSDK

@main
struct PlayBackDemoApp: App {

let sdkManager = PlayBackSDKManager()
let apiKey = "API_KEY"
var body: some Scene {
WindowGroup {
HomeView()
}
}

init() {
// Initialize the Playback SDK with the provided API key and base URL
PlayBackSDKManager.shared.initialize(apiKey: apiKey) { result in
switch result {
case .success(let license):
// Obtained license upon successful initialization
print("SDK initialized with license: \(license)")

// Register the video player plugin
let bitmovinPlugin = BitmovinPlayerPlugin()
VideoPlayerPluginManager.shared.registerPlugin(bitmovinPlugin)

case .failure(let error):
// Print an error message and set initializationError flag upon initialization failure
print("SDK initialization failed with error: \(error)")

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

import SwiftUI
import PlaybackSDK

struct PlayerTestView: View {

private let entryID = "ENTRY_ID"
private let authorizationToken = "JWT_TOKEN"

var body: some View {
VStack {
// Load player with the playback SDK
PlayBackSDKManager.shared.loadPlayer(entryID: entryID, authorizationToken: authorizationToken) { error in
handlePlaybackError(error)
}
.onDisappear {
// Remove the player here
}
Spacer()
}
.padding()
}

private func handlePlaybackError(_ error: PlaybackError) {
switch error {
case .apiError(let statusCode, let errorMessage):
print("\(errorMessage) Status Code \(statusCode)")
errorMessage = "\(errorMessage) Status Code \(statusCode)"
default:
print("Error loading HLS stream in PlaybackUIView: \(error.localizedDescription)")
errorMessage = "Error code and errorrMessage not found: \(error.localizedDescription)"
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,26 @@
}

@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")


@Stack {
@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 {
Expand All @@ -42,31 +47,46 @@
}
}

@Section(title: "Error Handling") {
@ContentAndMedia {
The library propagates errors through completion handlers. You can handle these errors to provide appropriate feedback to the user.
@Section(title: "Add a customization view") {
@ContentAndMedia {
Add the ability for users to customize sloths and select their powers.

@Image(source: 01-creating-section2.png, alt: "An outline of a sloth surrounded by four power type icons. The power type icons are arranged in the following order, clockwise from the top: fire, wind, lightning, and ice.")
}

@Stack {
@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")
}

**Example:**

Swift
@ContentAndMedia {
The Playback SDK sudasdasdsadsadsadsads or integrate with third-party video players. Refer to the full source code for details on creating custom plugins.

```swiftasdas.registerPlugin(YourCustomPlayerPlugin())
// Use the selectasded plugin for playback
pluginManager.selectedPlugin?.play()
```

```
PlaybackSDKManager.shared.initialize(apiKey: "YOUR_API_KEY") { result in
switch result {
case .success:
print("Playback SDK initialized successfully.")
@Image(source: "custom_plugin.png", alt: "Custom Video Player Plugin")
}

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)")
@ContentAndMedia {
...
}
}
```

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

}
}
Loading

0 comments on commit f2d7b61

Please sign in to comment.