Set up Recommendations

Automate the generation of a playlist based on a seed video for your iOS app.

If you have hundreds of videos hosted on or registered with your account, Recommendations automates the generation of a playlist based on a seed video and provides you options to customize the appearance and behavior of that playlist.


Screenshot of Recommendations view


In addition to the general iOS SDK requirements, the following items are required to implement Recommendations.

50 videos
This is the suggested minimum number of videos that should be in your JW Player library.
Recommendations featureIf this product is not already enabled in your account, contact your JW Player representative.

Configure the Recommendations display options

The following steps explain how to setup the Recommendations view:

  1. Create a Recommendations playlist in your JW Player dashboard.

  2. After creating the Recommendations playlist, on the DEVELOPER RESOURCES tab of the JW Player dashboard, copy the JSON URL.

  3. In your app, use JWRelatedContentConfigurationBuilder() to create a JWRelatedConfiguration object.

  4. Add the JSON URL (file). Be sure to change the value of the ?related_media_id= query to match the media ID of the playerItem.file URL.

  5. (Optional) Define autoplayTimer. This creates a break between the playback of videos and enables the countdown overlay to appear. The default value is 10 (seconds).

  6. (Optional) Define onComplete as autoplay. This property helps to extend a user's viewing session.

  7. (Optional) Use autoplayMessage property to define the message that displays when the countdown overlay appears. We suggest using __title__ will begin in xx seconds. The countdown message appears above the title and description of the next video to play. The default message is “Next up in xx”. xx represents the number of seconds remaining in the countdown as defined by autoplayTimer.

  8. Use JWPlayerConfigurationBuilder() to add the JWRelatedConfiguration object to the JWPlayerConfiguration object.

var relatedContentConfig = JWRelatedContentConfigurationBuilder()
    .url(URL(string: "JSON_URL")!)
    .autoplayMessage("__title__ will play in xx seconds")
var playerItem = try! JWPlayerItemBuilder()
    .file(URL(string: "VIDEO_URL")!)
var playerConfig = try! JWPlayerConfigurationBuilder()
NSError *error;
JWRelatedContentConfigurationBuilder *recBuilder = [[JWRelatedContentConfigurationBuilder alloc] init];
[recBuilder url:[NSURL URLWithString:@"JSON_URL"]];
[recBuilder autoplayMessage:@"__title__ will play in xx seconds"];
[recBuilder onComplete:JWRelatedOnCompleteAutoplay];
[recBuilder autoplayTimer:5];
JWRelatedContentConfiguration *recConfig = [recBuilder build];
JWPlayerItemBuilder *itemBuilder = [[JWPlayerItemBuilder alloc] init];
[itemBuilder file:[NSURL URLWithString:@"VIDEO_URL"]];
JWPlayerItem *item = [itemBuilder buildAndReturnError:&error];
JWPlayerConfigurationBuilder *builder = [[JWPlayerConfigurationBuilder alloc] init];
[builder playlist:@[item]];
[builder related:recConfig];
JWPlayerConfiguration *config = [builder buildAndReturnError:&error];

Related Delegates

func playerViewController(_ controller: JWPlayerViewController, relatedMenuOpenedWithItems items: [JWPlayerItem], withMethod method: JWRelatedInteraction)Triggers when the related view is opened
func playerViewController(_ controller: JWPlayerViewController, relatedMenuClosedWithMethod method: JWRelatedInteraction)Triggers when the related view is closed
func playerViewController(_ controller: JWPlayerViewController, relatedItemBeganPlaying item: JWPlayerItem, atIndex index: Int, withMethod method: JWRelatedInteraction)Triggers when a user selects an object in a related feed or the first item starts playing

Did this page help you?