Skip to content

Commit bfc446f

Browse files
committed
Added Playlist Feature
1 parent d750b72 commit bfc446f

File tree

6 files changed

+464
-18
lines changed

6 files changed

+464
-18
lines changed

CHANGELOG.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1+
12
# Changelog
23

34
All notable changes to this project will be documented in this file.
45

6+
## [0.3.0]
7+
8+
- FastPix iOS Player now supports playlist.
9+
- Create and manage playlists with multiple `FastPixPlaylistItems`.
10+
- Add playlist directly to the player using `addPlaylist()` method.
11+
- Auto-play option (`isAutoPlayEnabled`) to automatically continue playback with the next item.
12+
- Option to hide the SDK’s default controls (`hideDefaultControls`) for building custom UI.
13+
- Playlist state notifications via `NotificationCenter` (`FastPixPlaylistStateChanged`) for updating UI elements such as titles, buttons, or thumbnails.
14+
- Built-in navigation methods: `next()`, `previous()`, and `jumpTo(index:)` for moving between items.
15+
- Navigation methods can also be connected to custom UI buttons (e.g., Next/Previous/Episode selectors)
16+
517
## [0.2.0]
618

719
- FastPix iOS Player now supports DRM via Apple FairPlay for content protection.
@@ -18,5 +30,4 @@ All notable changes to this project will be documented in this file.
1830
- Fixed resolution option (e.g., `.set480p`).
1931
- Range-based resolution configuration.
2032
- **Rendition Order Customization**: Added support for ascending or descending rendition selection.
21-
- **Swift Package Manager Support**: SDK is installable via SPM using the repo URL.
22-
33+
- **Swift Package Manager Support**: SDK is installable via SPM using the repo URL.

README.md

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,123 @@ if let token = self.playbackToken {
195195
}
196196
```
197197

198+
## Playlist Support
199+
200+
FastPix iOS Player now supports playlists, allowing you to manage and navigate multiple videos within a single playback session.
201+
202+
### Create a Playlist
203+
204+
```swift
205+
let playlist = [
206+
FastPixPlaylistItem(
207+
playbackId: "<PLAYBACK_ID_1>",
208+
title: "Episode 1: <TITLE>",
209+
description: "<DESCRIPTION>",
210+
thumbnail: "https://example.com/thumbnail1.jpg",
211+
duration: "01:00:00", // format HH:MM:SS
212+
token: "<PLAYBACK_TOKEN>", // optional
213+
drmToken: "<DRM_TOKEN>" // optional
214+
),
215+
FastPixPlaylistItem(
216+
playbackId: "<PLAYBACK_ID_2>",
217+
title: "Episode 2: <TITLE>",
218+
description: "<DESCRIPTION>",
219+
thumbnail: "https://example.com/thumbnail2.jpg",
220+
duration: "00:45:00",
221+
token: "<PLAYBACK_TOKEN>",
222+
drmToken: "<DRM_TOKEN>"
223+
),
224+
FastPixPlaylistItem(
225+
playbackId: "<PLAYBACK_ID_3>",
226+
title: "Episode 3: <TITLE>",
227+
description: "<DESCRIPTION>",
228+
thumbnail: "https://example.com/thumbnail3.jpg",
229+
duration: "00:30:00",
230+
token: "<PLAYBACK_TOKEN>",
231+
drmToken: "<DRM_TOKEN>"
232+
)
233+
]
234+
```
235+
### Add Playlist to Player
236+
237+
```swift
238+
// Add the playlist directly to the player instance using this method
239+
240+
playerViewController.addPlaylist(playlist)
241+
```
242+
243+
### Enable Auto-Play
244+
245+
```swift
246+
// Automatically play the next item in the playlist
247+
248+
playerViewController.isAutoPlayEnabled = true
249+
```
250+
251+
### Hide Default Controls
252+
253+
```swift
254+
// Hide the SDK’s built-in player controls if you want custom UI
255+
256+
playerViewController.hideDefaultControls = true
257+
```
258+
259+
### Observe Playlist State Changes
260+
261+
You can observe playlist state updates (such as when the current item changes) using `NotificationCenter`.
262+
This allows you to update your UI (titles, buttons, progress, etc.) whenever the playlist state changes.
263+
264+
```swift
265+
override func viewDidLoad() {
266+
super.viewDidLoad()
267+
setupPlaylistStateObserver()
268+
}
269+
270+
private func setupPlaylistStateObserver() {
271+
NotificationCenter.default.addObserver(
272+
self,
273+
selector: #selector(playlistStateChanged),
274+
name: Notification.Name("FastPixPlaylistStateChanged"),
275+
object: playerViewController // IMPORTANT: Observe the specific player instance
276+
)
277+
}
278+
279+
@objc private func playlistStateChanged(_ notification: Notification) {
280+
DispatchQueue.main.async {
281+
// Example: Update current video title
282+
self.updateCurrentTitle()
283+
284+
// Example: Update button visibility
285+
self.updateButtonVisibility()
286+
287+
// Log the update
288+
if let current = self.playerViewController.currentPlaylistItem {
289+
NSLog("current item: \(current)")
290+
}
291+
}
292+
}
293+
```
294+
295+
### Playlist Navigation
296+
297+
FastPix Player SDK provides built-in methods to navigate between playlist items. You can move to the next or previous video, or jump directly to a specific index in the playlist. These methods can also be tied to your own UI controls (like **Next**, **Previous**, or **Jump to Episode** buttons), making it easy to customize the playback experience for your users. The index is zero-based (e.g., `jumpTo(index: 0)` plays the first item), and you can combine these navigation methods with the Playlist State Observer to dynamically update the UI (such as the current video title, button states, or thumbnails).
298+
299+
#### Example Usage
300+
301+
```swift
302+
// Go to the next playlist item
303+
304+
playerViewController.next()
305+
306+
// Go back to the previous playlist item
307+
308+
playerViewController.previous()
309+
310+
// Jump to a specific item in the playlist (e.g., index 2)
311+
312+
playerViewController.jumpTo(index: 2)
313+
```
314+
198315
#### Each of these features is designed to enhance both flexibility and user experience, providing complete control over video playback, appearance, and user interactions in FastPix-player.
199316

200317
# Supporting tvOS
@@ -257,4 +374,4 @@ class TVPlayerViewController: UIViewController {
257374

258375
## Maturity
259376

260-
This SDK is currently in beta, and breaking changes may occur between versions even without a major version update. To avoid unexpected issues, we recommend pinning your dependency to a specific version. This ensures consistent behavior unless you intentionally update to a newer release.
377+
This SDK is currently in beta, and breaking changes may occur between versions even without a major version update. To avoid unexpected issues, we recommend pinning your dependency to a specific version. This ensures consistent behavior unless you intentionally update to a newer release.

0 commit comments

Comments
 (0)