Specify playback start time

Define the location where playback of a media asset should begin.

In some use cases, you may not want playback to start at the beginning of a media asset. While not features supplied by the iOS SDK, here are two possible use cases:

  • Continuing to consume a media asset that was previously started, but not completed
  • Sharing a link to a specific moment in a media asset

The startTime property enables you to define the number of seconds from the start of a media asset when playback should begin.


Add startTime to a PlaylistItem

Use the following steps to include this functionality in your app:

  1. Identify the number of seconds from the start of a media asset when playback should begin.
  2. Set the startTime for the PlaylistItem. The following code examples show how to set the startTime with the value captured in the previous step.
- (void)viewDidLoad {
    [super viewDidLoad];

    // Do any additional setup after loading the view.
    NSString *url = CONTENT_URL;
    
    JWPlaylistItem *item = [[JWPlaylistItem alloc] init];    
    item.file = url;
    item.startTime = 20;    // Time (seconds) where to begin the video.

    JWConfig *config = [[JWConfig alloc] initWithContentUrl:url];
    config.playlist = @[item];

    self.player = [[JWPlayerController alloc] initWithConfig:config];
}
var url: CONTENT_URL

override func viewDidLoad() {
    super.viewDidLoad()
    let item = JWPlaylistItem()
    item.file = url
    item.startTime = 20  // Time (seconds) where to begin the video.

    let config = JWConfig(contentURL: url)
    Config.playlist = [item]

    player = JWPlayerController(config: config)
}

Updated about a year ago


Specify playback start time


Define the location where playback of a media asset should begin.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.