您可以通過擴展OpportunityGenerator介面來實現您自己的機會生成器。
建立自定義機會生成器。
例如:
/**
* Class implementing AdobePSDK.OpportunityGenerator interface
*/
CustomOpportunityGenerator = function () {
};
CustomOpportunityGenerator.prototype = {
constructor: CustomOpportunityGenerator,
configureCallbackFunc: function (item, client, mode, playhead, playbackRange) {
// the playhead represents the initial playback position
// the playback range represents the initial playback range
// the item property indicates the current AdobePSDK.MediaPlayerItem associated with this generator
// the initial set of timed metadata can be obtain through the item property
var timedMetadatas = item.timedMetadata;
},
updateCallbackFunc: function (playhead, playbackRange) {
// when an opportunity is created by this generator
// we need to notify the TVSDK through the client property
client.resolve (opportunity);
},
…
};
建立使用自定義機會生成器的自定義內容工廠。
例如:
/**
* Class implementing AdobePSDK.ContentFactory interface
*/
CustomContentFactory = function () {
};
CustomContentFactory.prototype = {
constructor: CustomContentFactory,
retrieveOpportunityGeneratorsCallbackFunc: function (item) {
var result = [];
result.push (new CustomOpportunityGenerator());
return result;
},
…
};
為要播放的媒體流註冊自定義內容工廠。
在UI Framework播放器中,可以按如下方式指定自定義內容工廠:
var advertisingFactory = new CustomContentFactory();
var playerWrapper = ptp.videoPlayer('.videoDiv', {
player: {
mediaPlayerItemConfig: {
advertisingFactory: advertisingFactory
},
mediaResource: {
resourceUrl:'Specify Resource Url'
}
}
});