Configuring Multiple Sources

Just like a regular video tag you can provide a JW Player multiple video formats. JW Player will pick the optimal source given the browser it is rendered in based on the order provided. It is important to do this as not every browser will support every media format. At this point all browsers support MP4 files so if you are using progressive media formats it is good to put that as your first source. If you are using streaming media like HLS or DASH you can set it up to deliver whichever you prefer by putting the priority on the first source. 

It is not possible to switch sources once the player chooses a source without reloading the playlist. The sources block is not designed to provide fallback if an item 404s or becomes not available. 

Configuring Sources

Setting fallbacks is accomplished by creating a sources block within your playlist ​section. Here, we can list different sources for the same video file. The most common example of doing this is to put priority over a streaming media format over another. If no streaming media formats are supported, the player will choose the progressive mp4 to play. For example:

var playerInstance = jwplayer("myElement");
playerInstance.setup({
playlist: [{
        sources: [{ 
            file: "https://mySite.com/manifest.mpd"
        },{
            file: "https://mySite.com/playlist.m3u8"
        },{
            file: "https://mySite.com/file.mp4"
        }
]
}],
});

Configuring sources can also be done within a playlist, as mentioned in our configuration reference page. This will allow you to add multiple sources for each item in a playlist.

Sources and DRM

In order to configure multiple DRM types within a player embed, each DRM type must be specified within a drm object in a source array:

 jwplayer("myElement").setup({
playlist: [{
        sources: [{ 
            file: "//mySite.com/myFile.mpd",
              drm: {
                       widevine: {
                              url: "mywidevineserver.com/drm"
                              }
               }
        }]
}]
});
More information can be found in our DRM article.

Example

Here's an example of our player using an RTMP stream as a primary media file, with an MP4 file as a backup: ​

 

The player should render successfully between mobile devices and browsers with Flash. (Provided that it can play MP4 natively!)

Did you find this article helpful?

Please log in to rate this article.