This topic describes a way that the same HTML page can support delivering a mobile optimized player to mobile devices that support the Flash Player, while delivering a desktop optimized player to other devices. This example uses JavaScript to detect the device type and then determines which player to display.
Note: The steps outlined in this topic are for Flash based players and will not work in HTML5 players and may prevent HTML5 players from functioning.
When you are delivering video to a mobile device, you want to use a player that has the right size and controls for a small touch screen. When you are delivering video to a desktop, you want a player with mouse-oriented controls that will look good on a larger screen.
There are several approaches you can take to achieve this goal:
This approach requires:
The first element you need to add to your HTML page is a line to load the playerSwitcher.js JavaScript. This goes after the line that loads the Flash-only Player APIs:
<script type="text/javascript" src="http://admin.brightcove.com/js/BrightcoveExperiences.js"></script> <script type="text/javascript" src="http://example.com/js/playerSwitcher.js"></script>
In this release, the playerSwitcher.js file identifies Android 2.2 as a mobile device supporting Flash Player. As more mobile browsers add Flash Player support, you can add their user agent strings to playerSwitcher.js.
In another JavaScript snippet in your HTML page, provide the configuration parameters for your two players. For example:
<script type="text/javascript">
var desktopPlayer = {};
desktopPlayer.playerID = "30060000108218";
desktopPlayer.bgcolor = "#FFFFFF";
desktopPlayer.width = "966";
desktopPlayer.height = "546";
desktopPlayer["@videoPlayer"] = "17038";
desktopPlayer.isVid = "true";
desktopPlayer.isUI = "true";
desktopPlayer.dynamicStreaming = true;
var mobilePlayer = {};
mobilePlayer.playerID = "30300022726001";
mobilePlayer.bgcolor = "#FFFFFF";
mobilePlayer.width = "600";
mobilePlayer.height = "600";
mobilePlayer["@videoPlayer"] = "17038";
mobilePlayer.isVid = "true";
mobilePlayer.isUI = "true";
. . .
</script>
You can find these player configuration parameters in the player publishing code that you copied to a text file, or in Video Cloud Studio's Publishing module. At a minimum, you should supply values for the following player configuration parameters:
| Parameter | Description |
|---|---|
| playerID | The Video Cloud player ID. You can find this in the Publishing module. |
| publisherID | The publisher ID of your Video Cloud account. You can find this by clicking Account Info in Video Cloud Studio. |
| bgcolor | A six-digit hexadecimal representation of the player's background color. For example, bgcolor = "#FFFFFF"; represents white. If you omit this parameter, the player has a white background until it fully loads, which might not be the appearance you want. |
| width height |
Dimensions of the player in pixels. Mobile players should be smaller, depending on the size of the screen you are targeting. |
| isVid | Required for all video players. |
| isUI | Required for video players whose templates include UI elements other than the VideoPlayer component, such as a ChromelessVideoPlayer or VideoDisplay and MediaControls components. |
| @videoPlayer | For a single video player, this parameter specifies the video ID of the video to play. See Assigning content to players programmatically for complete information about other parameters you can use to specify what videos play in the player. |
For a full list of the available player configuration parameters, with descriptions of how to use them, read Player Configuration Parameters.
Finally, in the same JavaScript snippet, invoke the insertPlayer function:
<script type="text/javascript">
. . .
brightcove.insertPlayer(
"playerContainer",
"myPlayer",
desktopPlayer,
mobilePlayer
);
</script>
The result is an HTML page that displays your mobile-optimized player when it detects a mobile device that supports Flash, and displays your desktop-optimized player when no mobile device is detected.
Post new comment
Comments