Optional features

Timeshifting

All Bambuser players support DVR-style seeking in live broadcasts (with certain tradeoffs) by placing the player in a special timeshift mode.

Timeshift mode configures the player to use a video format which supports seeking. The main tradeoff is higher latency when watching live. Additionally, playback performance may suffer on very long broadcasts. We recommend that apps enable timeshift mode only when necessary, on a case by case basis, and normally view live broadcasts in the default low-latency mode.

Timeshifting must be configured at the time when a player is instantiated and can not be enabled on players that are in the default mode.

If the higher latency is considered problematic, you might want to let your viewers toggle between the default player (with low latency) and a player with timeshift enabled.

REMEMBER

If the resourceURI has expired or is not valid for repeated use, you will need to produce a new valid signature when creating a new player.

Timeshifting on Android

See the BroadcastPlayer setTimeshiftMode(boolean) method.

In your Activity on Android, you may implement a method which configures a new player in the desired mode, for example:

import com.bambuser.broadcaster.BroadcastPlayer;
// ...
public class PlayerActivity extends AppCompatActivity {
    // ...
    void switchMode(String resourceUri, boolean timeshiftMode) {
        // ...
        if (mBroadcastPlayer != null)
            mBroadcastPlayer.close();
        mBroadcastPlayer = new BroadcastPlayer(this, resourceUri, APPLICATION_ID, mBroadcastPlayerObserver);
        mBroadcastPlayer.setSurfaceView(mVideoSurface);
        mBroadcastPlayer.setTimeshiftMode(timeshiftMode);
        mBroadcastPlayer.load();
    }
}

Timeshifting on iOS

See the BambuserPlayer timeShiftModeEnabled property.

In your implementation of a UIViewController on iOS, you can add a method which configures a new player in the desired mode, for example:

- (void) switchMode:(BOOL)timeshiftMode forResourceUri:(NSString*)resourceUri {
    [bambuserPlayer stopVideo];
    [bambuserPlayer removeFromSuperview];
    bambuserPlayer = [[BambuserPlayer alloc] init];
    bambuserPlayer.delegate = self;
    bambuserPlayer.applicationId = appId;
    bambuserPlayer.timeShiftModeEnabled = timeshiftMode;
    float statusBarOffset = self.topLayoutGuide.length;
    bambuserPlayer.frame = CGRectMake(0, 0 + statusBarOffset, self.view.bounds.size.width, self.view.bounds.size.height - statusBarOffset);
    [self.view addSubview: bambuserPlayer];
    [self.view sendSubviewToBack: bambuserPlayer];
    [bambuserPlayer playVideo: resourceUri];
}

Timeshifting in the web player

See the custom web player timeshift(boolean) option and property.

To let your viewers toggle between default mode and timeshift mode in the web player, you could implement a method which configures a new player in the desired mode, for example:

// Set timeshift mode
function setupPlayer(resourceUri, timeshiftMode) {
  if (player) {
    // Pause playback
    player.pause();
    // Remove any event listeners you added
    player.removeEventListener('pause');
    // Remove player from DOM
    player.innerHTML = '';
  }
  // Create a new player with the desired timeshift mode.
  player = BambuserPlayer.create(document.getElementById('player'), resourceUri, {
    timeshift: timeshiftMode
  });
  player.play();
}

WARNING

The method described here might not be future proof as browser vendors are increasingly restrictive about allowing websites to programmatically start videos using the 'play()' function.