Package com.bramosystems.oss.player.playlist.client

Provides classes for working with various playlist file formats

See: Description

Package com.bramosystems.oss.player.playlist.client Description

Provides classes for working with various playlist file formats

Required Module

Modules that use the classes and interfaces in this package and its sub-packages should inherit the com.bramosystems.oss.player.playlist.Playlist module.

Working with playlists

Assuming we have the following playlist in JSPF format generated by some server side code (it is also possible to have it as a JSON file anyway):

 {
   "playlist" : {
      "title"         : "Sample JSPF Playlist Example",
      "creator"       : "Sikiru Braheem",
      "annotation"    : "Sample playlist created for BST Player API",
      "info"          : "http://oss.bramosystems.com/bst-player",
      "location"      : "http://oss.bramosystems.com/bst-player/demo/showcase/",
      "identifier"    : "201106_playlists_jspf",
      "date"          : "2011-05-08T17:10:47+01:00",
      "license"       : "http://creativecommons.org/licenses/by/3.0/",
      "track"         : [
       {  "location"      : ["applause.mp3"],
          "identifier"    : ["idx1"],
            "title"         : "Applause",
            "creator"       : "Unknown",
            "annotation"    : "Just an applause",
            "album"         : "Sample Playlist",
            "trackNum"      : 1,
            "duration"      : 5000 },
 
        {   "location"      : ["big-buck-bunny.mp4"],
            "identifier"    : ["idx2"],
            "title"         : "Big Buck Bunny",
            "creator"       : "Blender Foundation | www.blender.org",
            "annotation"    : "Big Buck Bunny Preview",
            "info"          : "www.bigbuckbunny.org",
            "image"         : "http://peach.blender.org/wp-content/uploads/poster_bunny_small.jpg",
            "album"         : "Sample Playlist",
            "trackNum"      : 2,
            "duration"      : 60000 },
 
        {   "location"      : ["traffic.flv"],
            "identifier"    : ["idx3"],
            "title"         : "Evening traffic shot",
            "creator"       : "Sikiru Braheem",
            "annotation"    : "Evening Traffic Shot",
            "info"          : "sbraheem /at/ bramosystems /dot/ com",
            "album"         : "Sample Playlist",
            "trackNum"      : 3,
            "duration"      : 10000 }
        ]
    }
 }
 
The example below illustrates how to use the playlist with the player widgets:

      RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, 
                              "http://example.com/playlists/sample-playlist-in-jspf-format.json");
      rb.sendRequest(null, new RequestCallback() {
 
          public void onResponseReceived(Request request, Response response) {
              SPFPlaylist pl = PlaylistFactory.parseJspfPlaylist(response.getText());  // parse playlist data to SPFPlaylist object
 
              // once available we can work with the various fields ...
              GWT.log("Playlist Title   : " + pl.getTitle());
              GWT.log("Playlist Creator : " + pl.getInfo());
 
              // see the entries in the playlist ...
              JsArray<Track> ts = pl.getTracks();
              for (int i = 0; i < ts.length(); i++) {
                  Track t = ts.get(i);
                  GWT.log("Track Title   : " + t.getTitle());
                  GWT.log("Track Creator : " + t.getCreator());
                  GWT.log("Track URL     : " + t.getLocation());
              }
 
              // if we had an existing player widget, we can add this playlist 
              // to the player as well ...
              playerWidget.addToPlaylist(pl.toPlaylist());
          }
 
          public void onError(Request request, Throwable exception) {
          }
      });
 
Other supported playlist formats can be used in a similar way with the PlaylistFactory.

Copyright © 2009-2013. All Rights Reserved.