|
| 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