com.bramosystems.oss.player.core.client
Class PlayerUtil

java.lang.Object
  extended by com.bramosystems.oss.player.core.client.PlayerUtil

public class PlayerUtil
extends Object

Utility class for various media player related functions.

Author:
Sikirulai Braheem

Constructor Summary
PlayerUtil()
           
 
Method Summary
static String formatMediaTime(long milliSeconds)
          Formats the specified time (in milliseconds) into time string in the format hh:mm:ss.
static PluginVersion getDivXPlayerPluginVersion()
          Detects the version of the DivX Web Player plugin available on the clients browser.
static PluginVersion getFlashPlayerVersion()
          Detects the version of the Flash Player plugin available on the clients browser.
static com.google.gwt.user.client.ui.Widget getMissingPluginNotice(Plugin plugin)
          Convenience method to get a widget that may be used to notify the user when a required plugin is not available.
static com.google.gwt.user.client.ui.Widget getMissingPluginNotice(Plugin plugin, String version)
          Convenience method to get a widget that may be used to notify the user when a required plugin is not available.
static com.google.gwt.user.client.ui.Widget getMissingPluginNotice(Plugin plugin, String title, String message, boolean asHTML)
          Returns a widget that may be used to notify the user when a required plugin is not available.
static AbstractMediaPlayer getPlayer(PlayerInfo playerInfo, String mediaURL, boolean autoplay, String height, String width)
          Utility method to get the player with the specified playerInfo.
static AbstractMediaPlayer getPlayer(Plugin plugin, String mediaURL, boolean autoplay)
          Utility method to get a player that best supports the specified mediaURL with the specified plugin feature.
static AbstractMediaPlayer getPlayer(Plugin plugin, String mediaURL, boolean autoplay, String height, String width)
          Utility method to get a player that best supports the specified mediaURL with the specified plugin feature.
static AbstractMediaPlayer getPlayer(String mediaURL, boolean autoplay, String height, String width)
          Utility method to get a player that best supports the specified mediaURL.
static PlayerInfo getPlayerInfo(String providerName, String playerName)
          Returns the PlayerInfo object describing the features of the specified playerName from the specified providerName.
static Set<String> getPlayerNames(String playerProvider)
          Returns the name of all players available from the specified playerProvider
static Set<String> getPlayerProviderNames()
          Returns the name of all available player providers.
static PluginInfo getPluginInfo(Plugin plugin)
          Returns the PluginInfo object describing the features of the specified plugin
static PluginVersion getQuickTimePluginVersion()
          Detects the version of the QuickTime plugin available on the clients browser.
static PluginVersion getVLCPlayerPluginVersion()
          Detects the version of the VLC Media Player plugin available on the clients browser.
static PluginVersion getWindowsMediaPlayerPluginVersion()
          Detects the version of the Windows Media Player plugin available on the clients browser.
static boolean isHTML5CompliantClient()
          Checks if the browser implements the HTML 5 specification.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlayerUtil

public PlayerUtil()
Method Detail

formatMediaTime

public static String formatMediaTime(long milliSeconds)
Formats the specified time (in milliseconds) into time string in the format hh:mm:ss.

The hours part of the formatted time is omitted if milliseconds time is less than 60 minutes.

Parameters:
milliSeconds - media time to be formatted
Returns:
the formatted time as String

getPlayer

public static AbstractMediaPlayer getPlayer(String mediaURL,
                                            boolean autoplay,
                                            String height,
                                            String width)
                                     throws LoadException,
                                            PluginNotFoundException,
                                            PluginVersionException
Utility method to get a player that best supports the specified mediaURL.

A suitable player is determined based on the plugin available on the browser as well as its suitability to playback the specified media.

NOTE: If the media is served with a special streaming protocol such as MMS and RTSP, mediaURL should be specified in its absolute form. Otherwise mediaURL should end in a standard media format extension e.g. .mp3, .wma, .mov, .flv ...

Parameters:
mediaURL - the URL of the media to playback
autoplay - true to start playing automatically, false otherwise
height - the height of the player
width - the width of the player.
Returns:
a suitable player implementation
Throws:
LoadException - if an error occurs while loading the media.
PluginVersionException - if the required plugin version is not installed on the client.
PluginNotFoundException - if the required plugin is not installed on the client.

getPlayer

public static AbstractMediaPlayer getPlayer(Plugin plugin,
                                            String mediaURL,
                                            boolean autoplay,
                                            String height,
                                            String width)
                                     throws LoadException,
                                            PluginNotFoundException,
                                            PluginVersionException
Utility method to get a player that best supports the specified mediaURL with the specified plugin feature.

A suitable player is determined based on the features/capabilities derivable from the player plugin, its availability on the browser, and its suitability to playback the specified media.

The current implementation considers the following features:

NOTE: If the media is served with a special streaming protocol such as MMS and RTSP, mediaURL should be specified in its absolute form. Otherwise mediaURL should end in a standard media format extension e.g. .mp3, .wma, .mov, .flv ...

Parameters:
plugin - the features of the required player plugin
mediaURL - the URL of the media to playback
autoplay - true to start playing automatically, false otherwise
height - the height of the player
width - the width of the player.
Returns:
a suitable player implementation
Throws:
LoadException - if an error occurs while loading the media.
PluginVersionException - if the required plugin version is not installed on the client.
PluginNotFoundException - if the required plugin is not installed on the client.
Since:
1.0
See Also:
getPlayer(String, boolean, String, String)

getPlayer

public static AbstractMediaPlayer getPlayer(Plugin plugin,
                                            String mediaURL,
                                            boolean autoplay)
                                     throws LoadException,
                                            PluginNotFoundException,
                                            PluginVersionException
Utility method to get a player that best supports the specified mediaURL with the specified plugin feature.

Parameters:
plugin - the features of the required player plugin
mediaURL - the URL of the media to playback
autoplay - true to start playing automatically, false otherwise
Returns:
a suitable player implementation
Throws:
LoadException - if an error occurs while loading the media.
PluginVersionException - if the required plugin version is not installed on the client.
PluginNotFoundException - if the required plugin is not installed on the client.
Since:
1.1
See Also:
getPlayer(Plugin, String, boolean, String, String)

getFlashPlayerVersion

public static PluginVersion getFlashPlayerVersion()
                                           throws PluginNotFoundException
Detects the version of the Flash Player plugin available on the clients browser.

Returns:
PluginVersion object wrapping the version numbers of the Flash Player on the browser.
Throws:
PluginNotFoundException - if a Flash Player plugin could not be found (especially if none is installed or the plugin is disabled).

getQuickTimePluginVersion

public static PluginVersion getQuickTimePluginVersion()
                                               throws PluginNotFoundException
Detects the version of the QuickTime plugin available on the clients browser.

Returns:
PluginVersion object wrapping the version numbers of the QuickTime plugin on the browser.
Throws:
PluginNotFoundException - if a QuickTime plugin could not be found. (especially if none is installed or the plugin is disabled).

getWindowsMediaPlayerPluginVersion

public static PluginVersion getWindowsMediaPlayerPluginVersion()
                                                        throws PluginNotFoundException
Detects the version of the Windows Media Player plugin available on the clients browser.

Returns:
PluginVersion object wrapping the version numbers of the plugin on the browser.
Throws:
PluginNotFoundException - if a plugin could not be found. (especially if none is installed or the plugin is disabled).

getVLCPlayerPluginVersion

public static PluginVersion getVLCPlayerPluginVersion()
                                               throws PluginNotFoundException
Detects the version of the VLC Media Player plugin available on the clients browser.

Returns:
PluginVersion object wrapping the version numbers of the plugin on the browser.
Throws:
PluginNotFoundException - if a plugin could not be found. (especially if none is installed or the plugin is disabled).
Since:
1.0

getDivXPlayerPluginVersion

public static PluginVersion getDivXPlayerPluginVersion()
                                                throws PluginNotFoundException
Detects the version of the DivX Web Player plugin available on the clients browser.

Returns:
PluginVersion object wrapping the version numbers of the plugin on the browser.
Throws:
PluginNotFoundException - if a plugin could not be found. (especially if none is installed or the plugin is disabled).
Since:
1.2

getMissingPluginNotice

public static com.google.gwt.user.client.ui.Widget getMissingPluginNotice(Plugin plugin,
                                                                          String title,
                                                                          String message,
                                                                          boolean asHTML)
Returns a widget that may be used to notify the user when a required plugin is not available. The widget provides a link to the plugin download page.

CSS Style Rules

Parameters:
plugin - the missing plugin
title - the title of the message
message - descriptive message to notify user about the missing plugin
asHTML - true if message should be interpreted as HTML, false otherwise.
Returns:
missing plugin widget.
Since:
0.6

getMissingPluginNotice

public static com.google.gwt.user.client.ui.Widget getMissingPluginNotice(Plugin plugin,
                                                                          String version)
Convenience method to get a widget that may be used to notify the user when a required plugin is not available.

This is same as calling getMissingPluginNotice(plugin, "Missing Plugin", "<<message>>", false)
<<message>> => [Plugin Name] [version] or later is required to play this media. Click here to get [Plugin Name]

Parameters:
plugin - the required plugin
version - the minimum version of the required plugin
Returns:
missing plugin widget.
Since:
0.6
See Also:
getMissingPluginNotice(Plugin, String, String, boolean)

getMissingPluginNotice

public static com.google.gwt.user.client.ui.Widget getMissingPluginNotice(Plugin plugin)
Convenience method to get a widget that may be used to notify the user when a required plugin is not available.

This is same as calling getMissingPluginNotice(plugin, "Missing Plugin", "<<message>>", false)
<<message>> => [Plugin Name] is required to play this media. Click here to get [Plugin Name]

Parameters:
plugin - the required plugin
Returns:
missing plugin widget.
Since:
0.6
See Also:
getMissingPluginNotice(Plugin, String, String, boolean)

isHTML5CompliantClient

public static boolean isHTML5CompliantClient()
Checks if the browser implements the HTML 5 specification.

Returns:
true if browser is HTML 5 compliant, false otherwise
Since:
1.1

getPluginInfo

public static PluginInfo getPluginInfo(Plugin plugin)
                                throws PluginNotFoundException
Returns the PluginInfo object describing the features of the specified plugin

Parameters:
plugin - the plugin
Returns:
PluginInfo object
Throws:
PluginNotFoundException - if the specified plugin is not available
Since:
1.3
See Also:
PluginInfo

getPlayerProviderNames

public static Set<String> getPlayerProviderNames()
Returns the name of all available player providers.

Returns:
names of player providers
Since:
1.3

getPlayerNames

public static Set<String> getPlayerNames(String playerProvider)
Returns the name of all players available from the specified playerProvider

Parameters:
playerProvider - the name of the player provider
Returns:
names of available players
Throws:
IllegalArgumentException - if playerProvider is not registered
Since:
1.3

getPlayerInfo

public static PlayerInfo getPlayerInfo(String providerName,
                                       String playerName)
Returns the PlayerInfo object describing the features of the specified playerName from the specified providerName.

Parameters:
providerName - name of the player provider
playerName - name of player
Returns:
the PlayerInfo object
Throws:
IllegalArgumentException - if providerName and/or playerName is not available
Since:
1.3
See Also:
PlayerInfo

getPlayer

public static AbstractMediaPlayer getPlayer(PlayerInfo playerInfo,
                                            String mediaURL,
                                            boolean autoplay,
                                            String height,
                                            String width)
                                     throws LoadException,
                                            PluginNotFoundException,
                                            PluginVersionException
Utility method to get the player with the specified playerInfo.

This method acts as a factory to instantiate player widgets from various providers.

Parameters:
playerInfo - the required player widget
mediaURL - the URL of the media to playback
autoplay - true to start playing automatically, false otherwise
height - the height of the player
width - the width of the player.
Returns:
the player implementation
Throws:
LoadException - if an error occurs while loading the media.
PluginVersionException - if the required plugin version is not installed on the client.
PluginNotFoundException - if the required plugin is not installed on the client.
Since:
1.3
See Also:
getPlayer(String, boolean, String, String)


Copyright © 2009-2011. All Rights Reserved.