Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (23 sloc) 1.2 KB

defineStreamHandler

This method handles stream requests.

Returns:

args - request object; parameters described below

cb - function expecting to be called with Error and/or an object containing { streams: [] } with an array of Stream Objects.

Request Parameters

type - type of the item that we're requesting streams for; e.g. movie, series, channel, tv (see Content Types)

id - a Metadata Item Hash defined as a combination of the Meta Object's id followed by season / episode or video_id, separated by a :, an example of this is tt0898266:9:17

Basic Example

addon.defineStreamHandler(function(args, cb) {
    if (args.type === 'movie' && args.id === 'tt1254207') {
        // serve one stream to big buck bunny
        // return addonSDK.Stream({ url: '...' })
        const stream = { url: 'http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4' }
        cb(null, { streams: [stream] })
    } else {
        // otherwise return no streams
        cb(null, { streams: [] })
    }
})

Stream Object Definition