### Custom Fullscreen Implementation Setup Source: https://developers.dailymotion.com/guides/getting-started-with-ios-sdk This snippet outlines the setup for a custom fullscreen implementation. It involves returning `nil` from `playerWillPresentFullscreenViewController`, and implementing `playerDidRequestFullscreen` and `playerDidExitFullScreen` to manage the fullscreen state manually. ```swift class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() Dailymotion.createPlayer(playerId: "PlayerID", playerDelegate: self) { playerView, error in } } } extension ViewController: DMPlayerDelegate { func playerWillPresentFullscreenViewController(_ player: DMPlayerView) -> UIViewController? { return nil } func playerDidRequestFullscreen(_ player: DMPlayerView) { // Move the player in fullscreen State // Call notifyFullscreenChanged() the player will update his state player.notifyFullscreenChanged() } func playerDidExitFullScreen(_ player: DMPlayerView) { // Move the player in initial State // Call notifyFullscreenChanged() the player will update his state player.notifyFullscreenChanged() } } ``` -------------------------------- ### Implement Fullscreen (Out-of-the-box) Source: https://developers.dailymotion.com/guides/getting-started-with-ios-sdk Utilize the SDK's built-in fullscreen feature by implementing `DMPlayerDelegate` and the `playerWillPresentFullscreenViewController` function. ```APIDOC ## Implement fullscreen The iOS SDK supports a built-in fullscreen feature as well as custom fullscreen implementations. ### Out-of-the-box implementation In order for the fullscreen functionality to work, you have to implement `DMPlayerDelegate` and `playerWillPresentFullscreenViewController` function where you have to return a view controller that can be presented on: ```swift class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() Dailymotion.createPlayer(playerId: "PlayerID", playerDelegate: self) { playerView, error in } } } extension ViewController: DMPlayerDelegate { func playerWillPresentFullscreenViewController(_ player: DMPlayerView) -> UIViewController { return self } } ``` **Checking fullscreen state :** 1. You can check at any time after Player creation if the Player is in fullscreen by calling `playerView.isFullscreen` that will return `true` if is in fullscreen mode or `false` if not. 2. Implementing from `DMPlayerDelegate` the `playerDidPresentationModeChange` function, you will get a `DMPlayerView.PresentationMode` enum that will contain all possible player presentation states : `inline`, `pictureInPicture` and `fullscreen`: ```swift extension ViewController: DMPlayerDelegate { func playerDidPresentationModeChange(_ player: DMPlayerView, presentationMode: DMPlayerView.PresentationMode) { switch presentationMode { case .fullscreen: break case .inline: break case .pictureInPicture: break default: break } } } ``` **Handling fullscreen orientation :** 1. Using `defaultFullscreenOrientation` parameter from `DMPlayerParameters` object passed to create Player in order to set the default orientation when user requests fullscreen. 2. Using the function `setFullscreen(fullscreen: Bool, orientation: DMPlayerFullscreenOrientation? = **nil**)` to overwrite the default orientation when programmatically want to switch to fullscreen. ``` -------------------------------- ### Install Dailymotion Python SDK from Source Source: https://developers.dailymotion.com/sdk/platform-sdk/python Installs the Dailymotion Python SDK by cloning the GitHub repository and running the setup script. This method is useful for development or if you need the latest unreleased version. ```bash git clone git@github.com:dailymotion/dailymotion-sdk-python.git cd dailymotion-sdk-python python setup.py install ``` -------------------------------- ### Implement Fullscreen (Custom) Source: https://developers.dailymotion.com/guides/getting-started-with-ios-sdk Implement a custom fullscreen experience by returning `nil` from `playerWillPresentFullscreenViewController` and handling `playerDidRequestFullscreen` and `playerDidExitFullScreen` delegates. ```APIDOC ### Custom implementation If you don’t want to use the out-of-the-box fullscreen feature, you can implement your own fullscreen experience starting from version 1.1.0. following the below steps: 1. Implement `DMPlayerDelegate` and `playerWillPresentFullscreenViewController` function where you have to return `nil` instead of a `UIViewController` 2. Implement `playerDidRequestFullscreen` and `playerDidExitFullScreen` delegates to handle the Fullscreen/Exit Fullscreen 3. Call `notifyFullscreenChanged()` after each orientation change ```swift class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() Dailymotion.createPlayer(playerId: "PlayerID", playerDelegate: self) { playerView, error in } } } extension ViewController: DMPlayerDelegate { func playerWillPresentFullscreenViewController(_ player: DMPlayerView) -> UIViewController? { return nil } func playerDidRequestFullscreen(_ player: DMPlayerView) { // Move the player in fullscreen State // Call notifyFullscreenChanged() the player will update his state player.notifyFullscreenChanged() } func playerDidExitFullScreen(_ player: DMPlayerView) { // Move the player in initial State // Call notifyFullscreenChanged() the player will update his state player.notifyFullscreenChanged() } } ``` Important: Calling `player.notifyFullscreenChanged()` is required after updating the Player state to either `inline` or `fullscreen`. Not calling it might affect monetisation and certain Player functionalities. ``` -------------------------------- ### Runtime Player Parameters Source: https://developers.dailymotion.com/guides/getting-started-with-ios-sdk Customize the Dailymotion player's behavior at runtime by adding additional parameters beyond the initial configuration. ```APIDOC ## PUT /player/runtime_parameters ### Description Adds runtime parameters to a Dailymotion player configuration to customize its behavior. ### Method PUT ### Endpoint /player/runtime_parameters ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **playerId** (string) - Required - The ID of the Dailymotion player. - **playerParameters** (DMPlayerParameters) - Required - An object containing runtime parameters. - **customConfig** (Dictionary) - Optional - Key-value pairs for custom configurations. - **allowIDFA** (bool) - Optional - Enables IDFA. - **allowPIP** (bool) - Optional - Enables Picture-in-Picture mode. - **defaultFullscreenOrientation** (.landscapeRight, .portrait, etc.) - Optional - Default orientation for fullscreen. - **mute** (bool) - Optional - Mutes the player on start. - **scaleMode** (.fit, .fill, etc.) - Optional - Scaling mode for the video. - **startTime** (Int) - Optional - The video start time in seconds. - **loop** (bool) - Optional - Enables video looping. - **logLevels** (Array) - Optional - Specifies log levels for debugging. ### Request Example ```swift var dmPlayerParameters = DMPlayerParameters() dmPlayerParameters.customConfig = ["keyvalues":"category=sport§ion=video", "dynamiciu":"USERID/12345"] dmPlayerParameters.allowIDFA = true dmPlayerParameters.allowPIP = true dmPlayerParameters.defaultFullscreenOrientation = .landscapeRight dmPlayerParameters.mute = true dmPlayerParameters.scaleMode = .fit dmPlayerParameters.startTime = 15 dmPlayerParameters.loop = false Dailymotion.createPlayer(playerId: "PlayerId", playerParameters: dmPlayerParameters, logLevels: [.all]) { playerView, error in // Handle player creation callback } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation that runtime parameters have been applied. #### Response Example ```json { "message": "Runtime parameters applied successfully." } ``` ``` -------------------------------- ### Player Preloading and Reusing Source: https://developers.dailymotion.com/guides/getting-started-with-ios-sdk Learn how to preload the Dailymotion player for a smoother user experience and how to reuse a player instance to load multiple videos efficiently. ```APIDOC ## Player Preloading and Reusing ### Description Optimize performance by preloading the player in advance and reuse existing player instances to load multiple videos, enhancing the user experience. ### Method `createPlayer`, `loadContent()` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Preload Player To preload the player, create a `DMPlayerView` instance and store it. When the user is ready, attach this instance to your view hierarchy and call `loadContent()` or `play()`. ### Reuse Player A single `DMPlayerView` instance can be reused to load multiple videos using the `loadContent()` method. ### Request Example ```swift // Preloading example let playerView = Dailymotion.createPlayer(playerId: "PlayerId") { ... } // Later, when ready to display: view.addSubview(playerView) playerView.loadContent("videoId") // Reusing example // Assuming 'playerView' is an existing instance playerView.loadContent("newVideoId") ``` ### Response No direct response for preloading or reusing, but the player instance becomes available for content loading. ``` -------------------------------- ### Create Player Source: https://developers.dailymotion.com/guides/getting-started-with-ios-sdk This section details how to create a Dailymotion player view and add it to your application's view hierarchy using async/await. ```APIDOC ## POST /player ### Description Creates a Dailymotion player view and attaches it to the view hierarchy. ### Method POST ### Endpoint /player ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **playerId** (string) - Required - The ID of the Dailymotion player. - **videoId** (string) - Required - The ID of the video to play. - **playerParameters** (DMPlayerParameters) - Optional - Parameters to configure the player. - **playerDelegate** (DMPlayerDelegate) - Optional - The delegate for player events. ### Request Example ```swift do { let playerView = try await Dailymotion.createPlayer(playerId: "<#playerId#>", videoId: "<#videoId#>", playerParameters: DMPlayerParameters(), playerDelegate: self) // Attach the created Player View to your player container View let constraints = [ playerView.topAnchor.constraint(equalTo: self.playerContainerView.topAnchor, constant: 0), playerView.bottomAnchor.constraint(equalTo: self.playerContainerView.bottomAnchor, constant: 0), playerView.leadingAnchor.constraint(equalTo: self.playerContainerView.leadingAnchor, constant: 0), playerView.trailingAnchor.constraint(equalTo: self.playerContainerView.trailingAnchor, constant: 0) ] NSLayoutConstraint.activate(constraints) } catch { print("Error creating player: \(error)") } ``` ### Response #### Success Response (200) - **playerView** (DMPlayerView) - The created Dailymotion player view. #### Response Example (Player view object is directly returned and attached to the view hierarchy) ``` -------------------------------- ### Out-of-the-box Fullscreen Implementation Source: https://developers.dailymotion.com/guides/getting-started-with-ios-sdk This snippet demonstrates the out-of-the-box fullscreen implementation by implementing the `DMPlayerDelegate` protocol and the `playerWillPresentFullscreenViewController` function. This function must return a `UIViewController` that can present the fullscreen view. ```swift class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() Dailymotion.createPlayer(playerId: "PlayerID", playerDelegate: self) { playerView, error in } } } extension ViewController: DMPlayerDelegate { func playerWillPresentFullscreenViewController(_ player: DMPlayerView) -> UIViewController { return self } } ``` -------------------------------- ### DMPlayerDelegate Implementation Source: https://developers.dailymotion.com/guides/getting-started-with-ios-sdk Implementing the DMPlayerDelegate protocol is mandatory for full functionality and monetization. It allows you to handle player events and actions. ```APIDOC ## POST /delegate/implementation ### Description Implements the DMPlayerDelegate protocol to handle player actions like opening URLs, presenting fullscreen, and presenting ads. ### Method POST ### Endpoint /delegate/implementation ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```swift extension ViewController: DMPlayerDelegate { func player(_ player: DMPlayerView, openUrl url: URL) { UIApplication.shared.open(url) } func playerWillPresentFullscreenViewController(_ player: DMPlayerView) -> UIViewController { return self } func playerWillPresentAdInParentViewController(_ player: DMPlayerView) -> UIViewController { return self } } ``` ### Response #### Success Response (200) - **Status** (string) - Indicates successful implementation. #### Response Example ```json { "status": "DMPlayerDelegate implemented successfully" } ``` ``` -------------------------------- ### Player Errors Source: https://developers.dailymotion.com/guides/getting-started-with-ios-sdk A comprehensive list of potential errors that can occur during player creation or playback, along with their descriptions and suggested handling. ```APIDOC ## Player Errors ### Description This section outlines the various errors that can be thrown by `CreatePlayer` and `DMPlayerDelegate` methods, providing guidance for error handling. ### Method Error Handling within the SDK ### Parameters None ### Error List | ERROR | ERROR DESCRIPTION | |---------------------------------------------|------------------------------------------------------------------------------------------------------------------| | `PlayerError.underlyingRemoteError(error: Error)` | Triggered by the embed Player and forwarded by the SDK. Details about possible video access errors are documented elsewhere. | | `PlayerError.advertisingModuleMissing` | Triggered by the SDK when the advertising module is missing. The Player will not run without it. | | `PlayerError.playerIdNotFound` | Triggered by the SDK when the Player ID cannot be found. | | `PlayerError.stateNotAvailable` | Triggered by the SDK when asking for the Player's current state, but the state is not available at that moment. | | `PlayerError.internetNotConnected` | Player request failed because the internet connection appears to be offline. Retry the call. | | `PlayerError.requestTimedOut` | Player request took longer than expected. Retry the call. | | `PlayerError.otherPlayerRequestError` | Other Player request related error. Check the logs for more information. | | `PlayerError.unexpected` | Triggered when something unexpected went wrong. Check the logs for more info. If the issue persists, contact support. | **Note:** `PlayerError` implements the Swift `Error` protocol and can be safely cast to `NSError`. ### Request Example ```swift func handlePlayerError(error: Error) { switch(error) { case PlayerError.advertisingModuleMissing : // Handle missing advertising module break; case PlayerError.stateNotAvailable : // Handle unavailable state break; case PlayerError.underlyingRemoteError(error: let remoteError): // Handle underlying remote error let nsError = remoteError as NSError if let errDescription = nsError.userInfo[NSLocalizedDescriptionKey], let errCode = nsError.userInfo[NSLocalizedFailureReasonErrorKey], let recovery = nsError.userInfo[NSLocalizedRecoverySuggestionErrorKey] { print("Player Error : Description: \(errDescription), Code: \(errCode), Recovery : \(recovery) ") } else { print("Player Error : \(nsError)") } break case PlayerError.requestTimedOut: print(error.localizedDescription) break case PlayerError.unexpected: print(error.localizedDescription) break case PlayerError.internetNotConnected: print(error.localizedDescription) break case PlayerError.playerIdNotFound: print(error.localizedDescription) break case PlayerError.otherPlayerRequestError: print(error.localizedDescription) break default: print(error.localizedDescription) break } } ``` ### Response N/A (Error handling is event-driven) ``` -------------------------------- ### Retrieve Dailymotion Player State Source: https://developers.dailymotion.com/guides/getting-started-with-web-sdk This example demonstrates how to retrieve the current state of the Dailymotion Player. The `getState()` method returns an object containing detailed information about the player, video, and any active advertisements. This data can be used for analytics or to control player behavior. Ensure the Dailymotion SDK is properly initialized before calling this method. ```javascript player.getState().then(function(state) { console.log(state); // Access specific properties like: // console.log(state.playerIsPlaying); // console.log(state.videoDuration); // console.log(state.adIsPlaying); }); ``` -------------------------------- ### Retrieve Player State Source: https://developers.dailymotion.com/guides/getting-started-with-ios-sdk Retrieve the current state of the Player at any time using the `getState(completion:)` method. ```APIDOC ## Retrieve Player state The Player state can be retrieved at any time using the `getState(completion:)` method: ```swift self.dmPlayerView?.getState(completion: { [weak self] (playerState) in print("playerIsPlaying : \(playerState?.playerIsPlaying)") print("videoId : \(playerState?.videoId)") print("playerError : \(playerState?.playerError)") }) ``` Find all available states in the iOS SDK Reference. ``` -------------------------------- ### Create a Placeholder for the Dailymotion Player Source: https://developers.dailymotion.com/guides/getting-started-with-web-sdk This snippet demonstrates how to create a `div` element that will serve as a placeholder for the Dailymotion player. An ID is assigned to this `div`, which will be used later to initialize the player via the Platform API. ```html
My Player placeholder
``` -------------------------------- ### Event Listeners Source: https://developers.dailymotion.com/guides/getting-started-with-ios-sdk Implement delegate protocols to listen for events triggered by the Player. Recommended to pass delegates in the `createPlayer` method. ```APIDOC ## Manage event listeners To listen to events triggered by the Player, you need to implement the 3 delegate protocols: `DMPlayerDelegate`, `DMVideoDelegate`, and `DMAdDelegate`. **Pass the delegate protocols in the** `createPlayer` **method:** ```swift Dailymotion.createPlayer(playerId: "PLAYER_ID", playerDelegate: self, videoDelegate: self, adDelegate: self, completion: { [weak self] (dmPlayer, error) in // Create Player Done }) ``` **Pass the delegate protocols to the created** `DMPlayerView` **instance:** ```swift Dailymotion.createPlayer(playerId: "PLAYER_ID", completion: { [weak self] (dmPlayer, error) in // Create Player Done dmPlayer?.playerDelegate = self dmPlayer?.videoDelegate = self dmPlayer?.adDelegate = self }) ``` To ensure all events are caught by your delegates, we recommend using the first approach with passing the delegates in the `createPlayer()` method. Find all available events in the iOS SDK Reference. ``` -------------------------------- ### Dailymotion Player Settings Object Structure Source: https://developers.dailymotion.com/guides/getting-started-with-web-sdk This JSON object represents the structure of the settings returned by the `getSettings()` method of a Dailymotion player. It includes various configuration options for the player's appearance and behavior. ```json { "aspectRatio": "16:9", "autostart": "on", "color": "D0021B", "enableAdsControls": true, "enableAutonext": true, "enableChannelLink": true, "enableContextualContent": true, "enableCustomRecommendations": true, "enableDMLogo": true, "enableInfo": true, "enablePlaybackControls": true, "enableAutomaticRecommendations": true, "enableSharing": true, "enableSharingUrlLocation": false, "enableStartPipExpanded": false, "enableStartscreenDMLink": false, "enableTitlesInVideoCards": true, "enableVideoTitleLink": true, "enableWaitForCustomConfig": true, "id": "PLAYER_ID", "pip": "instant", "watermarkImageType": "from_channel", "watermarkImageUrl": "", "watermarkLinkType": "from_channel", "watermarkLinkUrl": "" } ``` -------------------------------- ### Import Dailymotion SDK and UI Elements Source: https://developers.dailymotion.com/guides/getting-started-with-ios-sdk Imports necessary Dailymotion SDK frameworks and UI components for iOS development. This is a prerequisite for initializing and managing the player within a ViewController. ```swift import DailymotionPlayerSDK import AVFoundation import UIKit class ViewController: UIViewController { // Container View IBOutlet - host view for the player @IBOutlet weak var playerContainerView: UIView! ... ``` -------------------------------- ### Player Destruction/Release Source: https://developers.dailymotion.com/guides/getting-started-with-ios-sdk Understand how the Dailymotion player instance is automatically managed and released when the `DMPlayerView` object is no longer referenced. ```APIDOC ## Player Destruction/Release ### Description Details on the automatic lifecycle management of the player instance, which is released when no longer referenced by the `DMPlayerView` object. ### Method Automatic Reference Counting (ARC) ### Parameters None ### Request Example N/A (Automatic process) ### Response N/A (Automatic process) **Note:** The player instance is automatically destroyed when the `DMPlayerView` object is deallocated and its reference count drops to zero. ``` -------------------------------- ### Customize Player with Runtime Parameters - Swift Source: https://developers.dailymotion.com/guides/getting-started-with-ios-sdk Configures a Dailymotion player with various runtime parameters to customize its behavior. This includes setting custom key-value pairs, enabling IDFA and PIP, defining fullscreen orientation, muting playback, setting scale mode, start time, and loop behavior. ```swift var dmPlayerParameters = DMPlayerParameters() dmPlayerParameters.customConfig = ["keyvalues":"category=sport§ion=video", "dynamiciu":"USERID/12345"] dmPlayerParameters.allowIDFA = true dmPlayerParameters.allowPIP = true dmPlayerParameters.defaultFullscreenOrientation = .landscapeRight dmPlayerParameters.mute = true dmPlayerParameters.scaleMode = .fit dmPlayerParameters.startTime = 15 dmPlayerParameters.loop = false Dailymotion.createPlayer(playerId: "PlayerId", playerParameters: dmPlayerParameters, logLevels: [.all]) { playerView, error in } ``` -------------------------------- ### Implement DMPlayerDelegate Protocol - Swift Source: https://developers.dailymotion.com/guides/getting-started-with-ios-sdk Extends the ViewController to conform to the DMPlayerDelegate protocol, enabling the handling of player events. This includes opening URLs in the browser, providing a view controller for fullscreen presentations, and a view controller for ad presentations. ```swift extension ViewController: DMPlayerDelegate { func player(_ player: DMPlayerView, openUrl url: URL) { UIApplication.shared.open(url) } func playerWillPresentFullscreenViewController(_ player: DMPlayerView) -> UIViewController { return self } func playerWillPresentAdInParentViewController(_ player: DMPlayerView) -> UIViewController { return self } } ``` -------------------------------- ### Listen to Dailymotion PLAYER_START Event Source: https://developers.dailymotion.com/guides/getting-started-with-web-sdk This JavaScript code snippet illustrates how to add an event listener to capture the `PLAYER_START` event from a Dailymotion player. When the event fires, a callback function is executed, logging a message and the current player state. ```javascript player.on(dailymotion.events.PLAYER_START, (state) => { console.log("Received PLAYER_START event. Current state is:", state); }); ``` -------------------------------- ### Retrieve Dailymotion Player Settings Source: https://developers.dailymotion.com/guides/getting-started-with-web-sdk This JavaScript code snippet shows how to access the initial configuration of a Dailymotion player, including its ID, by using the `getSettings()` method. The method returns a promise that resolves with an object containing the player's settings. ```javascript dailymotion .getPlayer() .then((player) => { console.log(player.getSettings()); }) .catch((e) => console.error(e)); ``` -------------------------------- ### Customize Player Log Levels (Swift) Source: https://developers.dailymotion.com/guides/getting-started-with-ios-sdk Allows customization of player logging levels by passing desired log levels to the `createPlayer` method. Supports various levels like debug, info, error, and all. ```swift Dailymotion.createPlayer(playerId: "PlayerId", logLevels: [.all]) { playerView, error in } ``` -------------------------------- ### Embed Dailymotion Playlist using Player Embed Script Source: https://developers.dailymotion.com/guides/getting-started-with-web-sdk This script embeds a Dailymotion playlist onto your webpage. It requires a Player ID and a playlist ID. The script should be loaded directly on every page. ```html ``` -------------------------------- ### Add Dailymotion Player Library Script to HTML Source: https://developers.dailymotion.com/guides/getting-started-with-web-sdk This snippet shows how to include the Dailymotion Player library script in the HTML body. This script provides access to the Platform API for programmatic player creation. It should be placed before any code that interacts with the API. ```html ``` -------------------------------- ### Handle Fullscreen Presentation Mode Changes Source: https://developers.dailymotion.com/guides/getting-started-with-ios-sdk This snippet shows how to handle changes in the player's presentation mode by implementing the `playerDidPresentationModeChange` delegate method from `DMPlayerDelegate`. It allows reacting to states like `.fullscreen`, `.inline`, and `.pictureInPicture`. ```swift extension ViewController: DMPlayerDelegate { func playerDidPresentationModeChange(_ player: DMPlayerView, presentationMode: DMPlayerView.PresentationMode) { switch presentationMode { case .fullscreen: break case .inline: break case .pictureInPicture: break default: break } } } ``` -------------------------------- ### Add Runtime Parameters using iFrame Source: https://developers.dailymotion.com/guides/getting-started-with-web-sdk Adds runtime parameters like 'startTime' and 'mute' to a Dailymotion player embedded via iframe. The parameters are appended to the video URL in the 'src' attribute. This method is useful for basic runtime adjustments in iframe embeds. ```html // Replace {Player ID} with your own Player ID, and x84sh87 with your own video ID ``` -------------------------------- ### Embed Dailymotion Video using iFrame Source: https://developers.dailymotion.com/guides/getting-started-with-web-sdk Embeds a Dailymotion video using an iframe. This method provides basic UI customization but lacks advanced JavaScript-based features like Picture-in-Picture or API access. It is recommended for environments restricting JavaScript execution. ```html ``` -------------------------------- ### Dailymotion API GET Request Examples Source: https://developers.dailymotion.com/api/platform-api/perform-api-calls Examples of GET requests to retrieve video information from the Dailymotion API. These examples demonstrate fetching a list of videos with specific fields and retrieving details for a single video. They cater to both public and private API key usage. ```HTTP GET https://api.dailymotion.com/videos?fields=id,title,language&channel=news&limit=100 ``` ```HTTP GET https://partner.api.dailymotion.com/rest/videos?fields=id,title,language&channel=news&limit=100 ``` ```HTTP GET https://api.dailymotion.com/video/x3rdtfy ``` ```HTTP GET https://partner.api.dailymotion.com/rest/video/x3rdtfy ``` -------------------------------- ### Add a One-Time Dailymotion Event Listener Source: https://developers.dailymotion.com/guides/getting-started-with-web-sdk This JavaScript example shows how to add an event listener that will only be invoked once. By passing an options object with `{ once: true }` to the `player.on()` method, the specified callback function for the `PLAYER_START` event will execute just the first time the event occurs. ```javascript player.on( dailymotion.events.PLAYER_START, (state) => { console.log("Received PLAYER_START event. Current state is:", state); }, { once: true } ); ``` -------------------------------- ### Example GET Request with Global Parameters Source: https://developers.dailymotion.com/api/platform-api/reference Demonstrates how to include global query parameters in a GET request to the Dailymotion API. This example shows the usage of 'family_filter' and 'localization' parameters to customize video search results. ```http GET https://api.dailymotion.com/video?family_filter=false&localization=it ``` -------------------------------- ### Customize Google Cast SDK UI Styles Source: https://developers.dailymotion.com/guides/getting-started-with-ios-sdk This Swift code provides an example of how to customize the appearance of the Google Cast SDK's user interface elements. It shows how to access the `GCKUIStyle` shared instance and modify properties for various components like navigation bar buttons, toolbars, and device choosers, before applying the changes. ```swift // Get the shared instance of GCKUIStyle let castStyle = GCKUIStyle.sharedInstance() // Set the property of the desired cast Views // Navigation bar buttons style castStyle.castViews.deviceControl.connectionController.navigation.buttonTextColor = .black // Tool bar style castStyle.castViews.deviceControl.connectionController.toolbar.backgroundColor = .white castStyle.castViews.deviceControl.connectionController.toolbar.buttonTextColor = .black // Connection controller style castStyle.castViews.deviceControl.connectionController.backgroundColor = .white castStyle.castViews.deviceControl.connectionController.iconTintColor = .black castStyle.castViews.deviceControl.connectionController.headingTextColor = .black castStyle.castViews.deviceControl.connectionController.bodyTextColor = .black // Device chooser style castStyle.castViews.deviceControl.deviceChooser.backgroundColor = .white castStyle.castViews.deviceControl.deviceChooser.iconTintColor = .black castStyle.castViews.deviceControl.deviceChooser.headingTextColor = .black castStyle.castViews.deviceControl.deviceChooser.captionTextColor = .black // Refresh all currently visible views with the assigned styles castStyle.apply() ``` -------------------------------- ### Dailymotion MRSS Feed Example (XML) Source: https://developers.dailymotion.com/guides/mrss-migration An example of a Dailymotion MRSS feed in XML format. This feed includes channel information and item details such as title, description, category, GUID, media content, and keywords. ```xml <![CDATA[Universal Pictures]]> http://www.universalpictures.com/ Wed, 10 Jul 2013 11:00:00 -0400 <![CDATA[Back to the Future]]> shortfilms 12345_back_to_the_future ``` -------------------------------- ### API Basics Source: https://developers.dailymotion.com/api/platform-api/getting-started Overview of fundamental concepts for interacting with the Dailymotion Platform API, including API calls, responses, and data types. ```APIDOC ## API Basics ### Description For a deeper understanding before diving into the API reference, explore the API basics. This section offers insights into how to interact with API objects, fields, and filters. ### Key Concepts * **Perform an API call** * **Understand an API response** * **Understand the different data types** ``` -------------------------------- ### Player Initialization and Core Controls Source: https://developers.dailymotion.com/sdk/player-sdk/android/sdk-migration-guide This section covers the primary methods for creating, loading, playing, and pausing the Dailymotion player, along with fullscreen control. ```APIDOC ## POST /websites/developers_dailymotion/createPlayer ### Description Initializes a new Dailymotion player instance with specified parameters. ### Method POST ### Endpoint /websites/developers_dailymotion/createPlayer ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **context** (Context) - Required - The Android context. - **playerId** (String) - Required - The ID of the player. - **videoId** (String?) - Optional - The ID of the video to load. - **playlistId** (String?) - Optional - The ID of the playlist to load. - **playerParameters** (PlayerParameters) - Required - Parameters for player configuration. - **playerListener** (PlayerListener?) - Optional - Listener for player events. - **videoListener** (VideoListener?) - Optional - Listener for video-specific events. - **adListener** (AdListener?) - Optional - Listener for ad-related events. - **playerSetupListener** (PlayerSetupListener) - Required - Listener for player setup status. ### Request Example ```json { "context": "YourAndroidContext", "playerId": "your_player_id", "videoId": "xabcde", "playerParameters": { ... }, "playerListener": null, "videoListener": null, "adListener": null, "playerSetupListener": { ... } } ``` ### Response #### Success Response (200) Indicates successful player initialization. #### Response Example (No explicit response body documented for initialization, success is indicated by the absence of errors and subsequent event callbacks.) ## POST /websites/developers_dailymotion/loadContent ### Description Loads content (video or playlist) into the player. ### Method POST ### Endpoint /websites/developers_dailymotion/loadContent ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **videoId** (String?) - Optional - The ID of the video to load. - **playlistId** (String?) - Optional - The ID of the playlist to load. - **startTime** (Long?) - Optional - The time in seconds to start playback. ### Request Example ```json { "videoId": "xabcde", "startTime": 60 } ``` ### Response #### Success Response (200) Indicates successful content loading. #### Response Example (No explicit response body documented for content loading, success is indicated by subsequent event callbacks.) ## POST /websites/developers_dailymotion/play ### Description Starts or resumes playback of the current video or playlist. ### Method POST ### Endpoint /websites/developers_dailymotion/play ### Parameters None ### Request Example ```json {} // Empty body ``` ### Response #### Success Response (200) Indicates playback has started or resumed. #### Response Example (No explicit response body documented for play action.) ## POST /websites/developers_dailymotion/pause ### Description Pauses the current video or playlist playback. ### Method POST ### Endpoint /websites/developers_dailymotion/pause ### Parameters None ### Request Example ```json {} // Empty body ``` ### Response #### Success Response (200) Indicates playback has been paused. #### Response Example (No explicit response body documented for pause action.) ## POST /websites/developers_dailymotion/setFullScreen ### Description Controls the fullscreen mode of the player. ### Method POST ### Endpoint /websites/developers_dailymotion/setFullScreen ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **fullscreen** (Boolean) - Required - Set to true to enable fullscreen, false to disable. - **orientation** (Orientation) - Required - The desired screen orientation. ### Request Example ```json { "fullscreen": true, "orientation": "LANDSCAPE" } ``` ### Response #### Success Response (200) Indicates the fullscreen state has been updated. #### Response Example (No explicit response body documented for setFullScreen action.) ``` -------------------------------- ### Overview and Basic Usage Source: https://developers.dailymotion.com/sdk/platform-sdk/php Demonstrates how to instantiate the PHP SDK and make a basic GET request to the Platform API. ```APIDOC ## Overview and Basic Usage ### Description This section explains how to initialize the Dailymotion PHP SDK and perform a simple API call to retrieve video information. ### Method GET ### Endpoint /videos ### Parameters #### Query Parameters - **fields** (array) - Required - Specifies which fields to retrieve for each video (e.g., `array('id', 'title', 'owner')`). ### Request Example ```php $api = new Dailymotion(); $result = $api->get( '/videos', array('fields' => array('id', 'title', 'owner')) ); ``` ### Response #### Success Response (200) - **result** (array) - Contains the requested video data as an array. #### Response Example ```json { "id": "x123abc", "title": "Example Video Title", "owner": "example_user" } ``` ``` -------------------------------- ### Reporting API - Introduction Source: https://developers.dailymotion.com/api/reporting-api/getting-started Introduction to the Reporting API, its capabilities, and access requirements. ```APIDOC ## Reporting API ### Description The Reporting API enables users to monitor content performance, analyze audience behavior, and optimize monetization strategies. It allows for the creation of custom reports in CSV format. ### Access The API is available only to verified Partners. ### Key Features - Asynchronous report generation. - Data delivered in CSV format. - Reports generated in UTC timezone. - Maximum of two concurrent reports. - Report generation time can take up to two hours. - Date range required: minimum 1 day, maximum 180 days. - Maximum of eight dimensions per report. - Reports are deleted after 48 hours. ``` -------------------------------- ### Initialize Dailymotion Player - Kotlin Source: https://developers.dailymotion.com/guides/getting-started-with-android-sdk This Kotlin code snippet demonstrates the basic initialization of the Dailymotion player. It requires a context, player ID, video ID, and listeners for setup success/failure and fullscreen requests. Ensure you replace placeholder IDs with your actual values. ```kotlin Dailymotion.createPlayer( context = context, playerId = "MY_PLAYER_ID", // replace by desired player id videoId = "A_VIDEO_ID", // replace by desired video id playerSetupListener = object : Dailymotion.PlayerSetupListener { override fun onPlayerSetupSuccess(player: PlayerView) { // Add PlayerView to view hierarchy } override fun onPlayerSetupFailed(error: PlayerError) { // PlayerView setup failed } }, playerListener = object : PlayerListener { override fun onFullscreenRequested(playerDialogFragment: DialogFragment) { // Show the playerDialogFragment on screen } } ) ``` -------------------------------- ### API Authentication Source: https://developers.dailymotion.com/api/platform-api/getting-started Guides and information on how to authenticate with the Dailymotion Platform API. ```APIDOC ## Authentication ### Description To access private information and perform account operations, authentication is required. Please refer to the authentication guides for detailed instructions on how to authenticate your requests. ### Authentication Guides [Link to Authentication Guides - not provided in text] ### Public vs. Private Access Public information is available without specific authentication. Private information and account operations require authentication and granted permissions. ``` -------------------------------- ### Create Dailymotion Player View using Async/Await - Swift Source: https://developers.dailymotion.com/guides/getting-started-with-ios-sdk Asynchronously creates a Dailymotion player view with a specified player ID, video ID, and optional parameters. It then adds the player view to the view hierarchy and activates constraints for proper layout. Error handling is included for the player creation process. ```swift do { // Please replace the Player ID with your own Player ID accessed via the Dailymotion Studio or Platform API. let playerView = try await Dailymotion.createPlayer(playerId: <#"xbzlf"#>, videoId: <#"x84sh87"#>, playerParameters: DMPlayerParameters() , playerDelegate: self) // Attach the created Player View to your player container View let constraints = [ playerView.topAnchor.constraint(equalTo: self.playerContainerView.topAnchor, constant: 0), playerView.bottomAnchor.constraint(equalTo: self.playerContainerView.bottomAnchor, constant: 0), playerView.leadingAnchor.constraint(equalTo: self.playerContainerView.leadingAnchor, constant: 0), playerView.trailingAnchor.constraint(equalTo: self.playerContainerView.trailingAnchor, constant: 0) ] // Activate created constraints NSLayoutConstraint.activate(constraints) } catch { // Handle erros print("Error creating player: \(error)") } } ``` -------------------------------- ### Basic API Call Example Source: https://developers.dailymotion.com/api/platform-api/perform-api-calls Demonstrates how to make a basic GET request to retrieve video information using either a public or private API key. ```APIDOC ## Basic API Call Example ### Description Retrieves a list of videos with specified fields (id, title, language) from the 'news' channel, with a limit of 100 results. ### Method GET ### Endpoint `https://api.dailymotion.com/videos` (Public API key) or `https://partner.api.dailymotion.com/rest/videos` (Private API key) ### Query Parameters - **fields** (string) - Required - Comma-separated list of fields to retrieve (e.g., `id,title,language`). - **channel** (string) - Required - The category or channel to filter videos by (e.g., `news`). - **limit** (integer) - Optional - The maximum number of videos to return (e.g., `100`). ### Request Example `GET https://api.dailymotion.com/videos?fields=id,title,language&channel=news&limit=100` ``` -------------------------------- ### Initialize Dailymotion Player with Video using Platform API Source: https://developers.dailymotion.com/guides/getting-started-with-web-sdk This JavaScript code initializes a Dailymotion player using the `createPlayer` method from the Platform API. It requires the placeholder `div` ID and specifies the video to be loaded via the `video` attribute. The promise resolves with the player instance or rejects with an error. ```javascript dailymotion .createPlayer("my-dailymotion-player", { video: "x84sh87", }) .then((player) => console.log(player)) .catch((e) => console.error(e)); ``` -------------------------------- ### GET /video/{video_id} Source: https://developers.dailymotion.com/migration-guide-new-embed-endpoint Retrieve embed information for a video, including embed_html and embed_url. Demonstrates the use of the 'context' query parameter for specifying a Player ID. ```APIDOC ## GET /video/{video_id} ### Description This endpoint retrieves embed information for a specific video. It shows how the `embed_html` and `embed_url` fields have been updated to reflect the new embed endpoint. It also demonstrates how to use the `context` query parameter to specify a Player ID for custom configurations. ### Method GET ### Endpoint `/video/{video_id}` ### Parameters #### Query Parameters - **fields** (string) - Optional - Comma-separated list of fields to retrieve. Example: `embed_html,embed_url` - **context** (string) - Optional - Specifies the Player ID for custom configuration. Format: `player%3D` ### Request Example `GET https://api.dailymotion.com/video/x84qh53?fields=embed_html&context=player%3Dxc394` ### Response #### Success Response (200) - **embed_html** (string) - The iframe embed code for the video, using the new embed endpoint. - **embed_url** (string) - The embed URL for the video, using the new embed endpoint. #### Response Example ```json { "embed_html": "" } ``` #### Response Example (embed_url) ```json { "embed_url": "https://geo.dailymotion.com/player/xc394.html?video=x84qh53" } ``` #### Error Handling - If no Player ID is specified, default player configuration is used and limited query parameters are supported. ``` -------------------------------- ### Dailymotion API Query with Player ID for embed_url Source: https://developers.dailymotion.com/migration-guide-new-embed-endpoint This example illustrates how to construct a Dailymotion API query to retrieve the `embed_url` while specifying a Player ID using the `context` parameter. ```http GET https://api.dailymotion.com/video/x84qh53?fields=embed_url&context=player%3Dxc394 ``` -------------------------------- ### Video Deleted Webhook Payload Example Source: https://developers.dailymotion.com/webhooks This JSON payload signifies a 'video.deleted' event. It includes the event type, timestamp, and data such as owner and video IDs. This webhook is triggered when a video is removed from the platform. ```json { "type":"video.deleted", "timestamp":1459864364000, "data":{ "owner_id":"xyz", "video_id":"xid" } } ```