To test this feature and view the example code, please see the Android SDK 5 Example Code Quick Start guide.

Yospace is a server-side ad insertion (SSAI) service that includes a Yospace Server at the head-end (controlling a SpotX ad server). To simplify the operations and the ad insertion, Yospace provides an Android client to communicate between the Yospace head-end on one side and the application and its player on the other. The Yospace client consists of some libraries (fetched through the build.gradle script) and some Java classes (slightly modified to work with the CONNECT SDK).

The yospace example code demonstrates how an application can be set up with the CONNECT Player SDK 5 as its player utilising the Yospace client and server.

The application can limit users' available functions like pause and rewind based on playerPolicyImpl passed down from the Yospace server.  It uses the player policy based on playback duration, isLive, streamURL and other such values to limit user actions and place adverts from the server within the timeline. Advert placement is normally decided by header information, what happens on click, and if the advert can be skipped.

The application is responsible for:

  • Implementing adverts for live and VOD playback.
  • Limiting user action within the player.

Example code

Create Yospace

To initialise Yospace, you must first create a PlayerAdapter which is constructed based upon if the stream is live or not.

public void onMoveToForeground() {
  	Log.d(Constant.getLogTag(), "App moved to foreground");


private void setupYospace() {
    // Initialise Yospace infrastructures
    PlayerAdapter adapter = mIsLive ? new PlayerAdapterLive(this, null) : new PlayerAdapter(this, mTimeline);
    if(mIsLive) {
        initialisePlayer(mStreamUrl, adapter);

After that, create a listener.

  //Initialise Yospace infrastructure for non-linear playback
  private void initialiseYospace(final PlayerAdapter adapter) {

    EventListener<Session> yoSpaceListener = event -> {
      // Retrieve the initialised session
      mSession = event.getPayload();

      switch (mSession.getState()) {
        case INITIALISED:
          // Instantiate a LogAnalyticEventListener to make Analytic events visible in the log
          mSession.setPlayerPolicy(new PlayerPolicyImpl());

          if (!mIsLive) {
                () -> {
                  // Initialise ExoPlayer infrastructure
                  initialisePlayer(mSession.getPlayerUrl(), adapter);
                  // update the timeline for vod
                  SessionNonLinear session = (SessionNonLinear) (mSession);
                  mTimeline.UpdateTimeline(session.getAdBreaks(), 0, session.getDuration());


        case NO_ANALYTICS:
              "initialiseYospace - Video URL does not refer to a Yospace stream, no analytics session created");

        case NOT_INITIALISED:
          Log.e(Constant.getLogTag(), "initialiseYospace - Failed to initialise analytics session");

    if (mIsLive) {
      Session.SessionProperties properties = new Session.SessionProperties(VIDEO_URL_LIVE).userAgent(USER_AGENT);
      SessionFactory factory = SessionFactory.createForLiveWithThread(yoSpaceListener, properties);
      mStreamUrl = factory.getPlayerUrl();
    } else {
      Session.SessionProperties properties = new Session.SessionProperties(VIDEO_URL_VOD).userAgent(USER_AGENT);
      properties.addDebugFlags(YoLog.DEBUG_PARSING | YoLog.DEBUG_POLLING | YoLog.DEBUG_HEARTBEAT_STATE);
      SessionNonLinear.create(yoSpaceListener, properties);

With this, a Yospace sessionFactory is created based on if the video is live or VOD and the parameters passed in by the USER_AGENT.

   * User agent, used when making calls for video content and adverts
  public static final String USER_AGENT = "YospaceSamplePlayer";

Implementing advert analytics

When constructing the Activity that contains Yospace, you may want to implement AnalyticsEventListener that has event listeners for things like onAdvetEnd and onTimelineUpdateReceived to implement your adverts. Below is an example of how you can implement this interface to add functionality.

public interface AnalyticEventListener {

  void onAdvertBreakEnd(AdBreak var1);

  void onAdvertBreakStart(AdBreak var1);

  void onAdvertEnd(Advert var1);

  void onAdvertStart(Advert var1);

  void onTimelineUpdateReceived(VmapPayload var1);

  void onTrackingUrlCalled(Advert var1, String var2, String var3);

  void onVastReceived(VastPayload var1);