Getting Started

The information in this document applies to version 1.0 and later. Check here for previous versions.

Developing with BST Player

The following sections describe the basic usage of the library. Before getting started, add the library to your application classpath and ensure your application module inherits the com.bramosystems.oss.player.core.Core module.

Embedding Windows Media Player

The WinMediaPlayer class in the com.bramosystems.oss.player.core.client.ui package wraps the Windows Media Player plugin as a GWT widget. The following code block describes an example:

SimplePanel panel = new SimplePanel();   // create panel to hold the player
AbstractMediaPlayer player = null;
try {
     // create the player, specifing URL of media
     player = new WinMediaPlayer("www.example.com/mediafile.wma");
     panel.setWidget(player); // add player to panel.
} catch(LoadException e) {
     // catch loading exception and alert user
     Window.alert("An error occured while loading");
} catch(PluginVersionException e) {
     // required plugin version is not available, alert user
     // possibly providing a link to the plugin download page.
     panel.setWidget(new HTML(".. some nice message telling the user
           to download plugin first .."));
} catch(PluginNotFoundException e) {
     // catch PluginNotFoundException and display a friendly notice.
     panel.setWidget(PlayerUtil.getMissingPluginNotice(Plugin.WinMediaPlayer));
}
                

The above code adds a Windows Media Player object to the panel and load the media at the specified URL. Controlling the plugin is straight forward as shown below:

player.playMedia();  // starts playback
player.pauseMedia();  // pauses playback
player.stopMedia();  // stops playback
player.setVolume(0.8); // sets the playback volume to 80% of maximum
                

Refer to the API documentation for details.

NOTE:- The WinMediaPlayer class requires Windows Media Player 7 or later

Working with QuickTime Player

Similar to the WinMediaPlayer class, the QuickTimePlayer class in the com.bramosystems.oss.player.core.client.ui package wraps the QuickTime plugin.

The following code block describes an example:

SimplePanel panel = new SimplePanel();   // create panel to hold the player
AbstractMediaPlayer player = null;
try {
     // create the player, specifing URL of media
     player = new QuickTimePlayer("www.example.com/mediafile.mp3");
     panel.setWidget(player); // add player to panel.
} catch(LoadException e) {
     // catch loading exception and alert user
     Window.alert("An error occured while loading");
} catch(PluginVersionException e) {
     // required plugin version is not available, alert user
     // possibly providing a link to the plugin download page.
     panel.setWidget(new HTML(".. some nice message telling the user
           to download plugin first .."));
} catch(PluginNotFoundException e) {
     // catch PluginNotFoundException and display a friendly notice.
     panel.setWidget(PlayerUtil.getMissingPluginNotice(Plugin.QuickTimePlayer));
}
                

NOTE:- The QuickTimePlayer class requires QuickTime 7.2.1 or later

Playing Flash supported media

The FlashMediaPlayer class in the com.bramosystems.oss.player.core.client.ui package is designed to handle playback of MP3 media and all video formats supported by the Flash plugin. However, only FLV video, MPEG 4 video and sound as well as MOV media formats are fully tested.

Similar to the previous examples the following code block shows how simple it can be:

SimplePanel panel = new SimplePanel();   // create panel to hold the player
AbstractMediaPlayer player = null;
try {
     // create the player, specifing URL of media
     player = new FlashMediaPlayer("www.example.com/mediafile.mp4");
     panel.setWidget(player); // add player to panel.
} catch(LoadException e) {
     // catch loading exception and alert user
     Window.alert("An error occured while loading");
} catch(PluginVersionException e) {
     // required plugin version is not available,
     // alert user possibly providing a link to the plugin download page.
     panel.setWidget(new HTML(".. some nice message telling the " +
           "user to download plugin first .."));
} catch(PluginNotFoundException e) {
     // catch PluginNotFoundException and display a friendly notice.
     panel.setWidget(PlayerUtil.getMissingPluginNotice(Plugin.FlashPlayer));
} 

NOTE:- Adobe Flash 9.0 or later is required

Embedding VLC Media Player

The VLCPlayer class in the com.bramosystems.oss.player.core.client.ui package wraps the VLC Media Player plugin. The plugin is awesome for its support of numerous media formats.

The following example gives shows a basic usage:

SimplePanel panel = new SimplePanel();   // create panel to hold the player
AbstractMediaPlayer player = null;
try {
     // create the player, specifing URL of media
     player = new VLCPlayer("www.example.com/mediafile.vob");
     panel.setWidget(player); // add player to panel.
} catch(LoadException e) {
     // catch loading exception and alert user
     Window.alert("An error occured while loading");
} catch(PluginVersionException e) {
     // required plugin version is not available,
     // alert user possibly providing a link to the plugin download page.
     panel.setWidget(new HTML(".. some nice message telling the " +
           "user to download plugin first .."));
} catch(PluginNotFoundException e) {
     // catch PluginNotFoundException and display a friendly notice.
     panel.setWidget(PlayerUtil.getMissingPluginNotice(Plugin.VLCPlayer));
}
                

NOTE:- VLC Player plugin 1.0.0 or later is required

Conclusion

With a simple set of API, BST Player provides an abstraction of popular media player plugins available on the web, therefore making media playback control much more fun filled. Even more appealing is the dynamic player plugin selection that makes the development of custom media player controls more interesting.