Flash Widget API Follow

Overview

(BETA) The Flash Widget API can be used to create custom widgets using the widget data created in the Topspin platform. Currently, there are three types of widgets that this API supports:

  • Streaming Player
  • Single Track Player
  • Email For Media

Since Topspin already provides these out of the box widgets, artists and developers may choose to create custom widgets with additional functionality and different UI, but still retain the Topspin event tracking based on campaigns. Using this API will abstract out any of the event logging logic so that is takes place automatically after registering the widget id (See below).

Getting Started

Developers must download the com.topspin.api package and add it to their classpath when compiling their AS3 widgets. The package can be downloaded either in swc format or a .zip file containing the classes and interfaces.

Initialization

You will need to load in a swf from our CDN (http://cdn.topspin.net/widgets/api/TSWidgetAPI.swf) and cast it as a com.topspin.api.data.ITSWidget.

Once the swf is loaded in, additional operations can take place. The following is an example of how the swf should be loaded into your application:

Loading an ITSWidget

http://pastie.org/2246945

Registering Your Widget ID

The widget id can be found in the published embed code from any of the 3 widgets types. 
For instance, the widget_id can be pulled from the flashvars below:

Streaming Widget Embed Code

http://pastie.org/2246951

Once you have an instance of the ITSWidget in your application, begin by adding listeners forcom.topspin.api.events.TSWidgetEvents and then register your widget id.

Register widget id

http://pastie.org/2246955

ITSWidget Interface

After you register and receive a TSWidgetEvent.WIDGET_LOAD_COMPLETE event, you may want to keep track of the campaign_id by using: ITSWidget.getCampaignId(). The campaign id must be sent in with each API call or the current campaign id is used. Use the ITSWidget to access data and perform certain actions against your widget_id.

com.topspin.api.data.ITSWidget

http://pastie.org/2246956

ITSPlaylist Interface

To play an media, audio or video data, you must use the ITSPlaylist interface to ensure that proper event logging take place. The ITSPlaylist manages all the media in any given widget_id whether it be a Streaming Player or E4M. Both AudioData and VideoData implement an ITrackData interface so that loading, playing, seeking and playback functionality is identical regardless of the media type. The following is the it ITSPlaylist interface followed by ITrackData.

com.topspin.api.data.ITSPlaylist

http://pastie.org/2246959

ITrackData Interface

The ITSPlaylist manages a set of ITrackData objects. This interface is implemented by two classes, AudioData and VideoData which are wrappers for Sound and Video flash objects. Using the ITrackData interface, loading, getting info, and playback calls are made simple.

com.topspin.api.data.media.ITrackData

http://pastie.org/2246960

Example

Additional documentation on the methods and such can be found in the source of the com.topspin.api package code. The source code for example project is also included in the .zip file.

Example: Topspin Flash Widget API Playground

Source Code

Latest source code is available on GitHub: 
http://github.com/amehta3000/topspin-flash-widget-api

Have more questions? Submit a request and our team will be able to help get you sorted.
Powered by Zendesk