Skip to content

Commit 75130a2

Browse files
committed
Initial commit
1 parent 5ff6820 commit 75130a2

File tree

5 files changed

+702
-1
lines changed

5 files changed

+702
-1
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright 2025 FastPix, Inc
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

Package.swift

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// swift-tools-version: 5.9
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let packageName = "FastpixVideoDataAVPlayer"
7+
8+
let package = Package(
9+
name: packageName,
10+
platforms: [
11+
.iOS(.v13) // Specify platform compatibility
12+
],
13+
products: [
14+
.library(
15+
name: packageName,
16+
targets: [packageName]
17+
),
18+
],
19+
dependencies: [
20+
// Add the Git URL package dependency here
21+
.package(url: "https://github.com/FastPix/iOS-core-data-sdk.git", from: "1.0.0")
22+
],
23+
targets: [
24+
.target(
25+
name: packageName,
26+
dependencies: [
27+
.product(name: "FastpixiOSVideoDataCore", package: "iOS-core-data-sdk") // Link the Git package to your local package
28+
]
29+
),
30+
.testTarget(
31+
name: "\(packageName)Tests",
32+
dependencies: [.target(name: packageName)]
33+
),
34+
]
35+
)

README.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
**FastPix Video Data AVPlayer** enhances the integration steps with [AVPlayer](https://github.com/iOS-video-data-avplayer), enabling the collection of player analytics. It enables automatic tracking of video performance metrics, making the data readily available on the [FastPix dashboard](https://dashboard.fastpix.io) for monitoring and analysis. While the SDK is developed in Swift, the published spm package currently includes only the Swift output.
2+
3+
# Key Features:
4+
5+
- **Track Viewer Engagement:** Gain insights into how users interact with your videos.
6+
- **Monitor Playback Quality:** Ensure video streaming by monitoring real-time metrics, including bitrate, buffering, startup performance, render quality, and playback failure errors.
7+
- **Error Management:** Identify and resolve playback failures quickly with detailed error reports.
8+
- **Customizable Tracking:** Flexible configuration to match your specific monitoring needs.
9+
- **Centralized Dashboard:** Visualize and compare metrics on the [FastPix dashboard](https://dashboard.fastpix.io) to make data-driven decisions.
10+
11+
# Prerequisites:
12+
13+
## Getting started with FastPix:
14+
15+
To track and analyze video performance, initialize the SDK with your Workspace key (learn more about [Workspaces here](https://docs.fastpix.io/docs/workspaces)):
16+
17+
1. **[Access the FastPix Dashboard](https://dashboard.fastpix.io)**: Log in and navigate to the Workspaces section.
18+
2. **Locate Your Workspace Key**: Copy the Workspace Key for client-side monitoring. Include this key in your Swift code on every page where you want to track video performance.
19+
20+
# Step 1: Installation and Setup:
21+
22+
To get started with this SDK, you can integrate it into your project using **Swift Package Manager (SPM)**. Follow these steps to add the package to your iOS project.
23+
24+
1. **Open your Xcode project** and navigate to:
25+
```
26+
File → Add Packages…
27+
```
28+
29+
2. **Enter the repository URL** for the FastPix SDK:
30+
```
31+
https://github.com/fastpix/iOS-video-data-avplayer.git
32+
```
33+
34+
3. **Choose the latest stable version** and click `Add Package`.
35+
36+
4. **Select the target** where you want to use the SDK and click `Add Package`.
37+
38+
39+
# Step 2: Basic Integration
40+
41+
To integrate this SDK into your project, follow these steps:
42+
43+
## Import the SDK:
44+
45+
First, import the SDK into your Swift project:
46+
47+
```swift
48+
import FastpixVideoDataAVPlayer
49+
```
50+
51+
## Initialize and Configure the SDK:
52+
53+
Create an instance of initAvPlayerTracking.
54+
55+
```swift
56+
import FastpixVideoDataAVPlayer
57+
58+
let fpDataSDK = initAvPlayerTracking()
59+
60+
let customMetadata = [
61+
workspace_id: "WORKSPACE_KEY", // Unique key to identify your workspace (replace with your actual workspace key)
62+
video_title: "Test Content", // Title of the video being played (replace with the actual title of your video)
63+
video_id: "f01a98s76t90p88i67x", // A unique identifier for the video (replace with your actual video ID for tracking purposes)
64+
]
65+
66+
// Track AVPlayer Layer
67+
fpDataSDK.trackAvPlayerLayer(
68+
playerLayer: playerLayer, // The AVPlayerLayer instance managing the playback
69+
customMetadata: customMetadata
70+
)
71+
72+
// Track AVPlayer
73+
fpDataSDK.trackAvPlayer(
74+
player: player, // The AVPlayer instance managing the playback
75+
customMetadata: customMetadata
76+
)
77+
78+
// Track AVPlayer Controller
79+
fpDataSDK.trackAvPlayerController(
80+
playerController: playerController, // The AVPlayerViewController instance managing the playback
81+
customMetadata: customMetadata
82+
)
83+
```
84+
85+
## Define player metadata
86+
87+
Check out the [user-passable metadata](https://docs.fastpix.io/docs/user-passable-metadata) documentation to see the metadata supported by FastPix. You can use custom metadata fields like `custom_1` to `custom_10` for your business logic, giving you the flexibility to pass any required values. Named attributes, such as `video_title` and `video_id`, can be passed directly as they are.
88+
89+
```swift
90+
let customMetadata = [
91+
workspace_id: "WORKSPACE_KEY", // Unique key to identify your workspace (replace with your actual workspace key)
92+
video_title: "Test Content", // Title of the video being played (replace with the actual title of your video)
93+
video_id: "f01a98s76t90p88i67x", // A unique identifier for the video (replace with your actual video ID for tracking purposes)
94+
viewer_id: "user12345", // A unique identifier for the viewer (e.g., user ID, session ID, or any other unique value)
95+
video_content_type: "series", // Type of content being played (e.g., series, movie, etc.)
96+
video_stream_type: "on-demand", // Type of streaming (e.g., live, on-demand)
97+
98+
// Custom fields for additional business logic
99+
custom_1: "", // Use this field to pass any additional data needed for your specific business logic
100+
custom_2: "", // Use this field to pass any additional data needed for your specific business logic
101+
102+
// Add any additional metadata
103+
]
104+
```
105+
106+
### Note:
107+
108+
Keep metadata consistent across different video loads to make comparison easier in your analytics dashboard.
109+
110+
### Changing video streams in player
111+
112+
When your application plays multiple videos back-to-back in the same player, it’s essential to notify the FastPix SDK whenever a new video starts; possibly in scenarios like playlist content/ video series or any other video that user wants to play.
113+
114+
```swift
115+
import FastpixVideoDataAVPlayer
116+
117+
let fpDataSDK = initAvPlayerTracking()
118+
119+
fpDataSDK.trackAvPlayerLayer(
120+
playerLayer: playerView.renderingView.playerLayer,
121+
customMetadata: customMetadata
122+
)
123+
124+
fpDataSDK.dispatchEvent(event: "videoChange", metadata: [
125+
video_id: "123def", // Unique identifier for the new video
126+
video_title: "Daalcheeni", // Title of the new video
127+
video_series: "Comedy Capsule", // Series name if applicable
128+
129+
// ... and other metadata
130+
])
131+
```
132+
133+
# Detailed Usage:
134+
135+
For more detailed steps and advanced usage, please refer to the official [FastPix Documentation](https://docs.fastpix.io/docs/av-player-ios).

0 commit comments

Comments
 (0)