### Install Brightcove Player CocoaPods Source: https://github.com/brightcoveos/ios-player-samples/blob/master/Freewheel/README.md Installs the Brightcove Player CocoaPods required for the project. This command-line operation ensures all necessary dependencies are managed via CocoaPods. ```sh pod install ``` -------------------------------- ### Verify Flutter Installation Source: https://github.com/brightcoveos/ios-player-samples/blob/master/PlayerUI/Flutter/README.md Command to check your Flutter installation and its dependencies. Useful for ensuring all necessary components are set up correctly. ```shell flutter doctor ``` -------------------------------- ### Start React Native Server Source: https://github.com/brightcoveos/ios-player-samples/blob/master/PlayerUI/ReactNative/README.md Starts the React Native development server, which bundles the JavaScript code and serves it to the application. This script is typically found in the package.json file. ```bash yarn start ``` -------------------------------- ### PAL SDK Integration Example (Conceptual) Source: https://github.com/brightcoveos/ios-player-samples/blob/master/SSAI/BasicSSAIPlayer-iOS/README.md This section refers to a project that provides an example of integrating the Brightcove SSAI plugin with the PAL SDK. To use this integration, download the PAL SDK XCFramework, add it to your project, and uncomment the relevant code sections marked with comments. ```swift // Uncomment the following lines to enable PAL SDK integration. // import PAL; // let palSDK = PALSDK.sharedInstance() // let adProvider = palSDK.adProvider() // let sessionProvider = BCOVPlayerSDKManager.sharedInstance().createSSAISessionProvider(withUpstreamSessionProvider: adProvider) ``` -------------------------------- ### Create BCOVPlaybackController using View Strategy with Brightcove iOS SDK Source: https://github.com/brightcoveos/ios-player-samples/blob/master/README.md Shows an example of creating a `BCOVPlaybackController` and assigning a custom view strategy to it. A view strategy determines how the player UI is presented and managed. ```swift // Sample code for creating a BCOVPlaybackController with a view strategy. // Example: // // Define your custom view strategy class conforming to BCOVPlayerViewStrategy // class MyCustomViewStrategy: NSObject, BCOVPlayerViewStrategy { // func layoutUI(for playerView: BCOVPlayerView, controlsView: UIView?) { // // Custom layout logic here // // Example: Add a custom button to the controls view // if let controls = controlsView { // let customButton = UIButton(type: .system) // customButton.setTitle("Custom Action", for: .normal) // customButton.frame = CGRect(x: 10, y: 10, width: 100, height: 30) // controls.addSubview(customButton) // } // } // } // // // In your player setup: // let playerView = BCOVPlayerView() // let playbackController = BCOVPlaybackController(playerView: playerView) // let customStrategy = MyCustomViewStrategy() // playerView.viewStrategy = customStrategy // // Load video... ``` -------------------------------- ### Install Node Dependencies with Yarn Source: https://github.com/brightcoveos/ios-player-samples/blob/master/PlayerUI/ReactNative/README.md Installs project dependencies using the Yarn package manager. This is a common first step in React Native projects. ```bash yarn install ``` -------------------------------- ### Detailed Flutter Diagnostics Source: https://github.com/brightcoveos/ios-player-samples/blob/master/PlayerUI/Flutter/README.md Provides verbose output for Flutter diagnostics, helpful for in-depth troubleshooting of installation and environment issues. ```shell flutter doctor -v ``` -------------------------------- ### Add Open Measurement SDK to Podfile Source: https://github.com/brightcoveos/ios-player-samples/blob/master/SSAI/BasicSSAIPlayer-iOS/README.md To include the IAB Open Measurement SDK in your project, add the specified pod to your Podfile. This ensures the SDK is installed and available for use with the Brightcove Player SDK for iOS. ```ruby pod 'Brightcove-Player-OpenMeasurement' ``` -------------------------------- ### Create BCOVPlaybackSessionConsumer with Brightcove iOS SDK Source: https://github.com/brightcoveos/ios-player-samples/blob/master/README.md Shows an example of creating a `BCOVPlaybackSessionConsumer`. This protocol allows for custom logic to be executed at various points during the playback session, such as during initialization or when errors occur. ```swift // Sample code for creating a BCOVPlaybackSessionConsumer. // This consumer can be added to the BCOVPlaybackController to observe and react to playback events. // Example: // class MySessionConsumer: NSObject, BCOVPlaybackSessionConsumer { // func playbackSession(_ session: BCOVPlaybackSession, didProgress progress: TimeInterval) { // print("Playback progress: \(progress)") // } // // Implement other methods as needed... // } // // // In your ViewController or Player setup: // let sessionConsumer = MySessionConsumer() // playbackController.add(sessionConsumer) ``` -------------------------------- ### Get Flutter Dependencies Source: https://github.com/brightcoveos/ios-player-samples/blob/master/PlayerUI/Flutter/README.md Command to fetch project dependencies for a Flutter project. Ensure you are in the project directory before running. ```shell flutter pub get ``` -------------------------------- ### Ad Playback with INVIDI Technologies Pulse using Brightcove iOS SDK Source: https://github.com/brightcoveos/ios-player-samples/blob/master/README.md Provides examples of playing advertisements managed by INVIDI Technologies Pulse. Covers various configurations for content and ad integration, including pre-rolls for SSAI Live Streams using Google IMA. ```swift // Sample code for Pulse ad playback. // This would involve configuring the player with Pulse ad rules // and potentially using Google IMA for SSAI scenarios. // Example: // import BrightcoveIMA // let adConfig = IMAAdConfiguration() // adConfig.adTagUrl = "YOUR_PULSE_AD_TAG_URL" // let adPlugin = IMAAVPlayerAdapter(player: player, adConfiguration: adConfig) // player.addPlugin(adPlugin) ``` -------------------------------- ### Server-Side Ad Insertion (SSAI) with Brightcove iOS SDK Source: https://github.com/brightcoveos/ios-player-samples/blob/master/README.md Demonstrates the use of the SSAI plugin for playing Dynamic Delivery content with or without Server-Side Ad Insertion. Includes examples of playing pre-roll ads for SSAI Live Streams using Google IMA. ```swift // Sample code for SSAI playback. // This typically involves setting up the player with SSAI-enabled content // and potentially configuring Google IMA for dynamic ad insertion. // Example: // // For SSAI, ensure your content URLs are configured for Dynamic Delivery. // // For pre-rolls with IMA: // let adConfig = IMAAdConfiguration() // adConfig.adTagUrl = "YOUR_IMA_AD_TAG_URL" // let adPlugin = IMAAVPlayerAdapter(player: player, adConfiguration: adConfig) // player.addPlugin(adPlugin) ``` -------------------------------- ### VAST 4.1+ Ad Verification Configuration Source: https://github.com/brightcoveos/ios-player-samples/blob/master/SSAI/BasicSSAIPlayer-iOS/README.md For VAST 4.1 and later, ad verification parameters must be configured within the `` nodes in the VAST document, adhering to the VAST 4.1 specification. This example shows the structure for defining an OMID verification resource. ```xml ``` -------------------------------- ### Create BCOVPlaybackController with Custom View Strategy (Swift) Source: https://github.com/brightcoveos/ios-player-samples/blob/master/PlayerUI/ViewStrategy/README.md This code demonstrates how to create a BCOVPlaybackController using a custom view strategy. The strategy defines a UIView that includes both the video view and a custom controls view. It also shows how to add the playback controller's view to the view hierarchy and configure playback options. ```swift func createPlaybackController(){ let sdkManager = BCOVPlayerSDKManager.sharedManager() let viewStrategy = { (videoView: UIView? , playbackController: BCOVPlaybackController) in { let myControlsView = MyControlsView() let controlsAndVideoView = UIView() videoView.frame = controlsAndVideoView.bounds controlsAndVideoView.addSubview(videoView) controlsAndVideoView.addSubview(myControlsView) playbackController.addSessionConsumer(myControlsView) // This container view will become `playbackController.view`. return controlsAndVideoView } playbackController = sdkManager.createPlaybackController(withViewStrategy: viewStrategy) playbackController.delegate = self playbackController.autoPlay = true playbackController.autoAdvance = true playbackController.view.frame = videoContainerView.bounds playbackController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight] videoContainerView.addSubview(playbackController.view) } ``` -------------------------------- ### Customizing Player Look and Feel with Brightcove iOS SDK Source: https://github.com/brightcoveos/ios-player-samples/blob/master/README.md Demonstrates how to customize the visual appearance and user interface of the Brightcove player. This includes modifying the BCOVPlayerUI, enhancing accessibility with VoiceOver properties, and implementing custom view strategies. ```swift // Sample code for PlayerUI customization. // This could involve subclassing BCOVPlayerUI or configuring // properties to alter the player's appearance and behavior. // Example: // let customView = UIView() // // ... add custom controls to customView // playerView.controlsView = customView // // Or for view strategy: // let myViewStrategy = MyCustomViewStrategy() // playerView.viewStrategy = myViewStrategy ``` -------------------------------- ### Update CocoaPods Repository Source: https://github.com/brightcoveos/ios-player-samples/blob/master/README.md Command to update the local CocoaPods repository to ensure the latest releases of Brightcove software components are used. This is a necessary step before building sample applications. ```bash pod repo update ``` -------------------------------- ### Core SDK Playback Features with Brightcove iOS SDK Source: https://github.com/brightcoveos/ios-player-samples/blob/master/README.md Showcases fundamental usage of the core Brightcove iOS SDK for video playback. Covers essential use cases such as implementing custom player controls, integrating analytics, and managing playback states. ```swift // Sample code for core player functionalities. // This includes setting up BCOVPlayerView, BCOVPlaybackController, // and handling playback events. // Example: // import BrightcovePlayerSDK // let playerView = BCOVPlayerView() // let playbackController = BCOVPlaybackController(playerView: playerView) // // ... configure playbackService and load video ... ``` -------------------------------- ### Set Up Lock Screen Playback Controls with Brightcove iOS SDK Source: https://github.com/brightcoveos/ios-player-samples/blob/master/README.md Demonstrates how to configure the necessary information for the AVPlayer so that playback controls appear on the iOS lock screen and in the Control Center. This enhances user experience by allowing control without unlocking the device. ```swift // Sample code for setting up lock screen controls. // This involves setting metadata like the current item's title, artist, and artwork. // Example: // // Assuming 'player' is your AVPlayer instance and playerItem has metadata // if let playerItem = player.currentItem { // let nowPlayingInfoCenter = MPNowPlayingInfoCenter.default() // var nowPlayingInfo: [String : Any] = [ // MPNowPlayingInfoPropertyElapsedPlaybackTime: playerItem.currentTime().seconds, // MPNowPlayingInfoPropertyPlaybackRate: player.rate, // MPNowPlayingInfoPropertyDefaultPlaybackRate: player.rate // ] // // if let title = playerItem.asset.commonMetadata.first(where: { $0.commonKey == .commonKeyTitle })?.value as? String { // nowPlayingInfo[MPNowPlayingInfoPropertyTitle] = title // } // // Add artist, album, artwork etc. similarly // // nowPlayingInfoCenter.nowPlayingInfo = nowPlayingInfo // } // // // Ensure you have "UIBackgroundModes" set to "audio" in your Info.plist ``` -------------------------------- ### Configure PlaybackService for Brightcove Video Source: https://github.com/brightcoveos/ios-player-samples/blob/master/PlayerUI/Flutter/flutter_bcov/README.md Shows how to set up the PlaybackService with required account and video IDs, along with optional policy key, auth token, and parameters for fetching Brightcove videos. ```dart PlaybackService( accountId: '5434391461001', policyKey: 'BCpkADawqM0T8lW3nMChuAbrcunBBHmh4YkNl5e6ZrKQwPiK_Y83RAOF4DP5tyBF_ONBVgrEjqW6fbV0nKRuHvjRU3E8jdT9WMTOXfJODoPML6NUDCYTwTHxtNlr5YdyGYaCPLhMUZ3Xu61L', videoId: '6140448705001', ); ``` -------------------------------- ### Initialize PlaybackController in Flutter Source: https://github.com/brightcoveos/ios-player-samples/blob/master/PlayerUI/Flutter/flutter_bcov/README.md Demonstrates how to initialize the PlaybackController with autoPlay and autoAdvance options for managing video playback behavior in the flutter_bcov package. ```dart PlaybackController( autoPlay: true, autoAdvance: true, ); ``` -------------------------------- ### Create Custom Audio & Subtitles Menu with Brightcove iOS SDK Source: https://github.com/brightcoveos/ios-player-samples/blob/master/README.md Details the process of creating a custom menu for managing audio tracks and subtitle selections within the Brightcove player. This allows for a tailored user experience beyond the default options. ```swift // Sample code for a custom Audio & Subtitles menu. // This typically involves accessing the available audio and subtitle tracks // from the BCOVPlaybackSession and providing UI elements (like buttons or pickers) // to switch between them. // Example: // // In your custom controls view or a separate menu view: // func setupAudioSubtitleMenu(session: BCOVPlaybackSession) { // if let audioTracks = session.audioTracks, !audioTracks.isEmpty { // // Create UI to select audio tracks // // Example: A segmented control or a list // print("Available audio tracks: \(audioTracks.count)") // } // // if let subtitleTracks = session.subtitleTracks, !subtitleTracks.isEmpty { // // Create UI to select subtitle tracks // print("Available subtitle tracks: \(subtitleTracks.count)") // } // } // // // Call this function when a BCOVPlaybackSession is available // playbackController.sessionConsumer = MySessionConsumer { session in // self.setupAudioSubtitleMenu(session: session) // } ``` -------------------------------- ### SwiftUI Player Integration with Brightcove iOS SDK Source: https://github.com/brightcoveos/ios-player-samples/blob/master/README.md Illustrates how to integrate `BCOVPlayerView` and `AVPlayerViewController` within a SwiftUI application. Covers presenting content in fullscreen mode over a SwiftUI TabView. ```swift // Sample code for SwiftUI integration. // This requires bridging UIKit components like BCOVPlayerView or AVPlayerViewController // into SwiftUI using UIViewRepresentable or UIViewControllerRepresentable. // Example: // import SwiftUI // import BrightcovePlayerSDK // // struct PlayerViewRepresentable: UIViewRepresentable { // func makeUIView(context: Context) -> BCOVPlayerView { // return BCOVPlayerView() // } // // func updateUIView(_ uiView: BCOVPlayerView, context: Context) { // // Update player properties if needed // } // } // // struct ContentView: View { // var body: some View { // PlayerViewRepresentable() // .onAppear { // // Load video content into the player // } // } // } ``` -------------------------------- ### Custom Subtitle Rendering with WebVTT using Brightcove iOS SDK Source: https://github.com/brightcoveos/ios-player-samples/blob/master/README.md Explains how to parse and display WebVTT subtitle files, allowing for customization of subtitle positioning and appearance. This provides flexibility beyond default rendering. ```swift // Sample code for custom subtitle rendering. // This might involve creating a custom AVPlayerLayerView and drawing subtitles manually // or intercepting subtitle events. // Example: // // Subtitle cues can be accessed via: // // player.currentItem?.textTracks.forEach { track in // // track.cues.forEach { cue in // // // Process cue data for custom rendering // // } // // } // // Or by implementing a BCOVPlaybackSessionConsumer to handle subtitle events. ``` -------------------------------- ### Omniture Analytics Tracking with Brightcove iOS SDK Source: https://github.com/brightcoveos/ios-player-samples/blob/master/README.md Illustrates how to integrate and use the Omniture plugin to track analytics events within the Brightcove player. This enables detailed user behavior analysis and reporting. ```swift // Sample code for Omniture analytics integration. // This would typically involve initializing the Omniture plugin and // configuring it with necessary tracking details. // Example: // import BrightcoveOminiture // let omniturePlugin = BCOmnitureAnalytics(pluginName: "Omniture", player: player) // player.addPlugin(omniturePlugin) // omniturePlugin.trackingManager.trackEvent("someEvent", parameters: ["key": "value"]) ``` -------------------------------- ### Offline Playback HLS Videos with Brightcove iOS SDK Source: https://github.com/brightcoveos/ios-player-samples/blob/master/README.md Demonstrates downloading HLS videos for offline playback. Requires a physical iOS device as simulators do not support video downloads. This functionality is crucial for applications requiring content accessibility without a network connection. ```swift // Sample code for offline playback functionality would be included here. // This would involve downloading HLS manifests and video segments, // and then configuring the player to play this local content. // Example: // let offlineVideo = BCOVOfflineVideo(hlsManifestURL: manifestURL, posterURL: posterURL) // let playbackService = BCOVPlaybackService(accountId: "YOUR_ACCOUNT_ID") // playbackService.retrieveOfflineVideo(offlineVideo, parameters: nil) { (session, _, _) in // // Configure player to play the offline session // } ``` -------------------------------- ### Create SSAI Session Provider with OMID Partner Source: https://github.com/brightcoveos/ios-player-samples/blob/master/SSAI/BasicSSAIPlayer-iOS/README.md When creating an SSAI session provider, provide a valid OMID Partner name using this signature. This enables the integration of the Open Measurement SDK for ad verification. ```objectivec [BCOVPlayerSDKManager createSSAISessionProviderWithUpstreamSessionProvider:omidPartner] ``` -------------------------------- ### Implement BCOVVideoPlayer Widget in Flutter Source: https://github.com/brightcoveos/ios-player-samples/blob/master/PlayerUI/Flutter/flutter_bcov/README.md Illustrates the usage of the BCOVVideoPlayer widget, which integrates PlaybackController and PlaybackService to display video content within a Flutter application. ```dart BCOVVideoPlayer( playbackController: PlaybackController( autoPlay: true, autoAdvance: true, ), playbackService: PlaybackService( accountId: '5434391461001', policyKey: 'BCpkADawqM0T8lW3nMChuAbrcunBBHmh4YkNl5e6ZrKQwPiK_Y83RAOF4DP5tyBF_ONBVgrEjqW6fbV0nKRuHvjRU3E8jdT9WMTOXfJODoPML6NUDCYTwTHxtNlr5YdyGYaCPLhMUZ3Xu61L', videoId: '6140448705001', ), ); ``` -------------------------------- ### Sidecar Subtitles with HLS Manifests using Brightcove iOS SDK Source: https://github.com/brightcoveos/ios-player-samples/blob/master/README.md Shows how to integrate WebVTT subtitles into an HLS manifest from within an iOS/tvOS app. Utilizes the SidecarSubtitles plugin, which is part of the core BrightcovePlayerSDK framework. ```swift // Sample code for SidecarSubtitles. // This involves ensuring the HLS manifest includes references to WebVTT files // and that the SDK is configured to parse and display them. // Example: // // The HLS manifest should contain lines like: // // #EXT-X-MEDIA:TYPE=SUBTITLE,GROUP-ID="subs",NAME="English",URI="subtitles-en.vtt",LANGUAGE="en" // // The SDK automatically handles parsing these if present. ``` -------------------------------- ### Picture-in-Picture Functionality with Brightcove iOS SDK Source: https://github.com/brightcoveos/ios-player-samples/blob/master/README.md Demonstrates how to enable and manage Picture-in-Picture (PiP) playback for videos using the Brightcove iOS SDK. This feature allows users to continue watching content while using other apps. ```swift // Sample code for Picture-in-Picture. // Requires configuring the AVAudioSession and enabling the PiP controller. // Example: // // Ensure background modes for audio are enabled in Info.plist // // let playerView = BCOVPlayerView() // // playerView.uses AVPlayerViewController = true // If using AVPlayerViewController integration // // playerView.allowsPictureInPicture = true // // // // To manually toggle PiP (if not using default controls): // // if playerView.isPictureInPicturePossible { // // playerView.enterPictureInPicture() // // } else { // // playerView.exitPictureInPicture() // // } ``` -------------------------------- ### Configure AVAudioSession with Mute State using Brightcove iOS SDK Source: https://github.com/brightcoveos/ios-player-samples/blob/master/README.md Shows how to configure the `AVAudioSession` based on the mute state of the AVPlayer. This is important for managing audio focus and background audio behavior correctly. ```swift // Sample code for AVAudioSession configuration based on mute state. // Example: // // Assuming 'player' is your AVPlayer instance // NotificationCenter.default.addObserver(forName: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: player.currentItem, queue: nil) { _ in // // Handle playback end // } // // // Observe player's volume change to infer mute state indirectly, or manage mute state separately. // player.volume = 0.0 // Mutes the player // // func configureAudioSession(isMuted: Bool) { // let audioSession = AVAudioSession.sharedInstance() // do { // if isMuted { // // Deactivate session if player is muted and no other audio is playing // try audioSession.setActive(false, options: .notifyOthersOnDeactivation) // } else { // // Activate session for playback // try audioSession.setCategory(.playback, mode: .default, options: []) // try audioSession.setActive(true) // } // } catch { // print("Error configuring AVAudioSession: \(error)") // } // } ``` -------------------------------- ### Add Font File to Xcode Project Source: https://github.com/brightcoveos/ios-player-samples/blob/master/README.md Instructions for adding the `bcovpuiiconfont.ttf` font file to an Xcode project. This font is required for Brightcove Player UI elements and needs to be copied into the app bundle. ```text Locate the `bcovpuiiconfont.ttf` file in the Pods/Brightcove-Player-SDK/ios/BrightcovePlayerSDK.framework folder. Add this file to your Xcode project listing so that the font file is copied into the app bundle. In the built app's bundle, the font file should end up at the same level as the app's Info.plist file. ``` -------------------------------- ### Handle 360 Video Navigation Changes in iOS Player Source: https://github.com/brightcoveos/ios-player-samples/blob/master/Player/Video360/README.md This Objective-C code snippet demonstrates how to implement the `BCOVPUIPlayerViewDelegate` to handle changes in 360 video navigation. It specifically addresses setting the device orientation to landscape when the projection method changes to VR Goggles mode. ```objective-c #import @interface YourViewController () @end @implementation YourViewController - (void)viewDidLoad { [super viewDidLoad]; // ... setup your BCOVPUIPlayerView ... self.playerView.delegate = self; } #pragma mark - BCOVPUIPlayerViewDelegate - (void)didSetVideo360NavigationMethod:(BCOVPUIVideo360NavigationMethod)navigationMethod projectionStyle:(BCOVVideo360ProjectionStyle)projectionStyle { if (projectionStyle == BCOVVideo360ProjectionStyleVRGoggles) { // Set device orientation to landscape NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft]; [[UIDevice currentDevice] setValue:value forKey:@"orientation"]; } } @end ``` -------------------------------- ### Attach Flutter Debugger Source: https://github.com/brightcoveos/ios-player-samples/blob/master/PlayerUI/Flutter/README.md Command to attach the Flutter debugger to a running application on a specific device. Requires the device ID and app ID. ```shell flutter attach -d 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' --app-id com.yourcompany.FlutterPlayer ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.