簡介
Brightcove 的傳遞規則可讓您利用剛剛即時資訊清單產生功能,使用自訂規則來控制內容傳遞給檢視者的方式。
如需傳遞規則的詳細資訊,請參閱下列內容:
安卓實作
要將傳遞規則與適用於Android的Native SDK一起使用,請按照以下步驟操作:
- 定義「交貨規則識別碼」的參數。
-
創建
HttpRequestConfig
使用您要應用的傳送規則。為您傳遞一個字符串值config_id
, 使用HttpRequestConfig.KEY_DELIVERY_RULE_CONFIG_ID
範圍。 -
將傳遞規則 ID 做為參數與目錄呼叫傳遞至播放 API。您可以使用
findVideoByID
或者findPlaylistByID
方法。這裡是代碼:public class MainActivity extends BrightcovePlayer { private final String TAG = this.getClass().getSimpleName(); @Override protected void onCreate(Bundle savedInstanceState) { // Assign the brightcoveVideoView before entering the superclass. // This allows for video player lifecycle management. setContentView(R.layout.activity_main); brightcoveVideoView = (BrightcoveExoPlayerVideoView) findViewById(R.id.brightcove_video_view); super.onCreate(savedInstanceState); // Get the event emitter from the SDK for notifications and logging EventEmitter eventEmitter = brightcoveVideoView.getEventEmitter(); // Create a catalog request to retrieve a video from your Video Cloud library Catalog catalog = new Catalog(eventEmitter, getString(R.string.account), getString(R.string.policy)); // Create HttpRequestConfig with the delivery rule you want to be applied. // Use the HttpRequestConfig.KEY_DELIVERY_RULE_CONFIG_ID with a String value for config_id HttpRequestConfig httpRequestConfig = new HttpRequestConfig.Builder() .addQueryParameter(HttpRequestConfig.KEY_DELIVERY_RULE_CONFIG_ID, "your rules id") .build(); // Add the HttpRequestConfig to the catalog request. catalog.findVideoByID(getString(R.string.videoId), httpRequestConfig, new VideoListener() { // Add the video found to the queue with add(). // Start playback of the video with start(). @Override public void onVideo(Video video) { Log.v(TAG, "onVideo: video = " + video); brightcoveVideoView.add(video); brightcoveVideoView.start(); } }); } }
iOS 實作
要將交付規則與iOS的本地SDK結合使用,請按照以下步驟操作:
- 定義「交貨規則識別碼」的參數。
-
將傳遞規則 ID 做為參數與目錄呼叫傳遞至播放 API。您可以使用
findVideoWithVideoID
或者findPlaylistWithPlaylistID
方法。這裡是代碼:- (void)requestContentFromPlaybackService { NSDictionary *playbackAPIParameters = @{@"config_id":@"your rules id"}; [self.playbackService findVideoWithVideoID:kViewControllerVideoID parameters:playbackAPIParameters completion:^(BCOVVideo *video, NSDictionary *jsonResponse, NSError *error) { if (video) { [self.playbackController setVideos:@[ video ]]; } else { NSLog(@"ViewController Debug - Error retrieving video playlist: `%@`", error); } }]; }