-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Playlist documentation on README file - Added example of loadPlaylist on Tutorial - Example of playlist controls and events on Tutorial - Preview Swift DocC command added to test tutorial locally
- Loading branch information
1 parent
a30b267
commit 7280775
Showing
8 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
65 changes: 65 additions & 0 deletions
65
...es/PlaybackSDK/Documentation.docc/Resources/PlayerTestPlaylistControlsAndEventsView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import SwiftUI | ||
import PlaybackSDK | ||
|
||
struct PlayerTestPlaylistControlsAndEventsView: View { | ||
|
||
@StateObject private var pluginManager = VideoPlayerPluginManager.shared | ||
private let entryIDs = ["ENTRY_ID1", "ENTRY_ID_2", "ENTRY_ID_3"] | ||
private let entryIDToPlay = "ENTRY_ID_2" // Optional parameter | ||
private let entryIdToSeek = "ENTRY_ID_TO_SEEK" | ||
private let authorizationToken = "JWT_TOKEN" | ||
|
||
var body: some View { | ||
VStack { | ||
// Load playlist with the playback SDK | ||
PlaybackSDKManager.shared.loadPlaylist(entryIDs: entryIDs, entryIDToPlay: entryIDToPlay, authorizationToken: authorizationToken) { errors in | ||
handlePlaybackError(errors) | ||
} | ||
.onReceive(pluginManager.selectedPlugin!.event) { event in | ||
if let event = event as? PlaylistTransitionEvent { // Playlist Event | ||
if let from = event.from.metadata?["entryId"], let to = event.to.metadata?["entryId"] { | ||
print("Playlist event changed from \(from) to \(to)") | ||
} | ||
} | ||
} | ||
.onDisappear { | ||
// Remove the player here | ||
} | ||
|
||
Spacer() | ||
|
||
Button { | ||
// You can use the following playlist controls | ||
pluginManager.selectedPlugin?.first() // Play the first video | ||
pluginManager.selectedPlugin?.playPrevious() // Play the previous video | ||
pluginManager.selectedPlugin?.playNext() // Play the next video | ||
pluginManager.selectedPlugin?.last() // Play the last video | ||
pluginManager.selectedPlugin?.seek(to: entryIdToSeek) { success in // Seek to a specific video | ||
if (!success) { | ||
let errorMessage = "Unable to seek to \(entryIdToSeek)" | ||
} | ||
} | ||
pluginManager.selectedPlugin?.activeEntryId() // Get the active video Id | ||
} label: { | ||
Image(systemName: "list.triangle") | ||
} | ||
|
||
Spacer() | ||
} | ||
.padding() | ||
} | ||
|
||
private func handlePlaybackErrors(_ errors: [PlaybackAPIError]) { | ||
|
||
for error in errors { | ||
switch error { | ||
case .apiError(let statusCode, let message, let reason): | ||
let message = "\(message) Status Code \(statusCode), Reason: \(reason)" | ||
print(message) | ||
default: | ||
print("Error code and errorrMessage not found: \(error.localizedDescription)") | ||
} | ||
} | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
Sources/PlaybackSDK/Documentation.docc/Resources/PlayerTestPlaylistView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import SwiftUI | ||
import PlaybackSDK | ||
|
||
struct PlayerTestPlaylistView: View { | ||
|
||
private let entryIDs = ["ENTRY_ID1", "ENTRY_ID_2", "ENTRY_ID_3"] | ||
private let entryIDToPlay = "ENTRY_ID_2" // Optional parameter | ||
private let authorizationToken = "JWT_TOKEN" | ||
|
||
var body: some View { | ||
VStack { | ||
// Load playlist with the playback SDK | ||
PlaybackSDKManager.shared.loadPlaylist(entryIDs: entryIDs, entryIDToPlay: entryIDToPlay, authorizationToken: authorizationToken) { errors in | ||
handlePlaybackError(errors) | ||
} | ||
.onDisappear { | ||
// Remove the player here | ||
} | ||
Spacer() | ||
} | ||
.padding() | ||
} | ||
|
||
private func handlePlaybackErrors(_ errors: [PlaybackAPIError]) { | ||
|
||
for error in errors { | ||
switch error { | ||
case .apiError(let statusCode, let message, let reason): | ||
let message = "\(message) Status Code \(statusCode), Reason: \(reason)" | ||
print(message) | ||
default: | ||
print("Error code and errorrMessage not found: \(error.localizedDescription)") | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
# This is a convenience script to preview Swift DocC documentation to prepare for GitHub Pages publishing | ||
# Source: https://swiftlang.github.io/swift-docc-plugin/documentation/swiftdoccplugin/previewing-documentation | ||
|
||
swift package --disable-sandbox preview-documentation --target PlaybackSDK |