實施自定義業務機會生成器

通過擴展OpportunityGenerator介面,您可以實施自己的機會生成器。

  1. 建立自訂商機產生器。

    例如:

    /** 
    * 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); 
        }, 
        … 
    }; 
    
  2. 建立自訂內容工廠,使用自訂商機產生器。

    例如:

    /** 
      * Class implementing AdobePSDK.ContentFactory interface 
    */ 
    CustomContentFactory = function () { 
    }; 
    
    CustomContentFactory.prototype = { 
           constructor: CustomContentFactory, 
           retrieveOpportunityGeneratorsCallbackFunc: function (item) { 
                var result = []; 
                result.push (new CustomOpportunityGenerator()); 
                return result; 
        }, 
        … 
    }; 
    
  3. 註冊要播放的媒體串流的自訂內容工廠。

    在UI Framework播放器中,您可以指定自訂內容工廠,如下所示:

    var advertisingFactory = new CustomContentFactory(); 
    var playerWrapper = ptp.videoPlayer('.videoDiv', { 
     player: { 
            mediaPlayerItemConfig: { 
                    advertisingFactory: advertisingFactory 
            }, 
                mediaResource: { 
                    resourceUrl:'Specify Resource Url' 
           } 
      } 
    }); 
    

本頁內容