use of tv.freewheel.ad.request.config.VideoAssetConfiguration in project android-player-samples by BrightcoveOS.
the class MainActivity method setupFreeWheel.
private void setupFreeWheel() {
// change this to new FrameLayout based constructor.
FreeWheelController freeWheelController = new FreeWheelController(this, brightcoveVideoView, eventEmitter);
// configure your own IAdManager or supply connection information
freeWheelController.setAdURL("http://demo.v.fwmrm.net/");
freeWheelController.setAdNetworkId(90750);
freeWheelController.setProfile("3pqa_android");
/*
* Choose one of these to determine the ad policy (basically server or client).
* - 3pqa_section - uses FW server rules - always returns a preroll and a postroll. It should return whatever midroll slots you request though.
* - 3pqa_section_nocbp - returns the slots that you request.
*/
// freeWheelController.setSiteSectionId("3pqa_section");
freeWheelController.setSiteSectionId("3pqa_section_nocbp");
eventEmitter.on(FreeWheelEventType.SHOW_DISPLAY_ADS, new EventListener() {
@Override
public void processEvent(Event event) {
@SuppressWarnings("unchecked") List<ISlot> slots = (List<ISlot>) event.properties.get(FreeWheelController.AD_SLOTS_KEY);
ViewGroup adView = (ViewGroup) findViewById(R.id.ad_frame);
// Clean out any previous display ads
for (int i = 0; i < adView.getChildCount(); i++) {
adView.removeViewAt(i);
}
for (ISlot slot : slots) {
adView.addView(slot.getBase());
slot.play();
}
}
});
eventEmitter.on(EventType.DID_SET_VIDEO, new EventListener() {
@Override
public void processEvent(Event event) {
brightcoveVideoView.start();
}
});
eventEmitter.on(FreeWheelEventType.WILL_SUBMIT_AD_REQUEST, new EventListener() {
@Override
public void processEvent(Event event) {
Video video = (Video) event.properties.get(Event.VIDEO);
IAdContext adContext = (IAdContext) event.properties.get(FreeWheelController.AD_CONTEXT_KEY);
AdRequestConfiguration adRequestConfiguration = (AdRequestConfiguration) event.properties.get(FreeWheelController.AD_REQUEST_CONFIGURATION_KEY);
IConstants adConstants = adContext.getConstants();
// This overrides what the plugin does by default for setVideoAsset() which is to pass in currentVideo.getId().
VideoAssetConfiguration fwVideoAssetConfiguration = new VideoAssetConfiguration("3pqa_video", adConstants.ID_TYPE_CUSTOM(), // FW uses their duration as seconds; Android is in milliseconds
video.getDuration() / 1000, adConstants.VIDEO_ASSET_DURATION_TYPE_EXACT(), adConstants.VIDEO_ASSET_AUTO_PLAY_TYPE_ATTENDED());
adRequestConfiguration.setVideoAssetConfiguration(fwVideoAssetConfiguration);
NonTemporalSlotConfiguration companionSlot = new NonTemporalSlotConfiguration("300x250slot", null, 300, 250);
companionSlot.setCompanionAcceptance(true);
adRequestConfiguration.addSlotConfiguration(companionSlot);
// Add preroll
Log.v(TAG, "Adding temporal slot for prerolls");
TemporalSlotConfiguration prerollSlot = new TemporalSlotConfiguration("larry", adConstants.ADUNIT_PREROLL(), 0);
adRequestConfiguration.addSlotConfiguration(prerollSlot);
// Add midroll
Log.v(TAG, "Adding temporal slot for midrolls");
int midrollCount = 1;
int segmentLength = (video.getDuration() / 1000) / (midrollCount + 1);
TemporalSlotConfiguration midrollSlot;
for (int i = 0; i < midrollCount; i++) {
midrollSlot = new TemporalSlotConfiguration("moe" + i, adConstants.ADUNIT_MIDROLL(), segmentLength * (i + 1));
adRequestConfiguration.addSlotConfiguration(midrollSlot);
}
// Add postroll
Log.v(TAG, "Adding temporal slot for postrolls");
TemporalSlotConfiguration postrollSlot = new TemporalSlotConfiguration("curly", adConstants.ADUNIT_POSTROLL(), video.getDuration() / 1000);
adRequestConfiguration.addSlotConfiguration(postrollSlot);
// Add overlay
Log.v(TAG, "Adding temporal slot for overlays");
TemporalSlotConfiguration overlaySlot = new TemporalSlotConfiguration("shemp", adConstants.ADUNIT_OVERLAY(), 8);
adRequestConfiguration.addSlotConfiguration(overlaySlot);
}
});
freeWheelController.enable();
}
use of tv.freewheel.ad.request.config.VideoAssetConfiguration in project android-player-samples by BrightcoveOS.
the class MainActivity method setupFreeWheel.
private void setupFreeWheel() {
// change this to new FrameLayout based constructor.
FreeWheelController freeWheelController = new FreeWheelController(this, brightcoveVideoView, eventEmitter);
// configure your own IAdManager or supply connection information
freeWheelController.setAdURL("http://demo.v.fwmrm.net/");
freeWheelController.setAdNetworkId(90750);
freeWheelController.setProfile("3pqa_android");
/*
* Choose one of these to determine the ad policy (basically server or client).
* - 3pqa_section - uses FW server rules - always returns a preroll and a postroll. It should return whatever midroll slots you request though.
* - 3pqa_section_nocbp - returns the slots that you request.
*/
// freeWheelController.setSiteSectionId("3pqa_section");
freeWheelController.setSiteSectionId("3pqa_section_nocbp");
eventEmitter.on(FreeWheelEventType.SHOW_DISPLAY_ADS, new EventListener() {
@Override
public void processEvent(Event event) {
@SuppressWarnings("unchecked") List<ISlot> slots = (List<ISlot>) event.properties.get(FreeWheelController.AD_SLOTS_KEY);
ViewGroup adView = (ViewGroup) findViewById(R.id.ad_frame);
// Clean out any previous display ads
for (int i = 0; i < adView.getChildCount(); i++) {
adView.removeViewAt(i);
}
for (ISlot slot : slots) {
adView.addView(slot.getBase());
slot.play();
}
}
});
eventEmitter.on(FreeWheelEventType.WILL_SUBMIT_AD_REQUEST, new EventListener() {
@Override
public void processEvent(Event event) {
Video video = (Video) event.properties.get(Event.VIDEO);
IAdContext adContext = (IAdContext) event.properties.get(FreeWheelController.AD_CONTEXT_KEY);
IConstants adConstants = adContext.getConstants();
AdRequestConfiguration adRequestConfiguration = (AdRequestConfiguration) event.properties.get(FreeWheelController.AD_REQUEST_CONFIGURATION_KEY);
// This overrides what the plugin does by default for setVideoAsset() which is to pass in currentVideo.getId().
VideoAssetConfiguration fwVideoAssetConfiguration = new VideoAssetConfiguration("3pqa_video", adConstants.ID_TYPE_CUSTOM(), // FW uses their duration as seconds; Android is in milliseconds
video.getDuration() / 1000, adConstants.VIDEO_ASSET_DURATION_TYPE_EXACT(), adConstants.VIDEO_ASSET_AUTO_PLAY_TYPE_ATTENDED());
adRequestConfiguration.setVideoAssetConfiguration(fwVideoAssetConfiguration);
NonTemporalSlotConfiguration companionSlot = new NonTemporalSlotConfiguration("300x250slot", null, 300, 250);
companionSlot.setCompanionAcceptance(true);
adRequestConfiguration.addSlotConfiguration(companionSlot);
// Add preroll
Log.v(TAG, "Adding temporal slot for prerolls");
TemporalSlotConfiguration prerollSlot = new TemporalSlotConfiguration("larry", adConstants.ADUNIT_PREROLL(), 0);
adRequestConfiguration.addSlotConfiguration(prerollSlot);
// Add midroll
Log.v(TAG, "Adding temporal slot for midrolls");
int midrollCount = 1;
int segmentLength = (video.getDuration() / 1000) / (midrollCount + 1);
TemporalSlotConfiguration midrollSlot;
for (int i = 0; i < midrollCount; i++) {
midrollSlot = new TemporalSlotConfiguration("moe" + i, adConstants.ADUNIT_MIDROLL(), segmentLength * (i + 1));
adRequestConfiguration.addSlotConfiguration(midrollSlot);
}
// Add postroll
Log.v(TAG, "Adding temporal slot for postrolls");
TemporalSlotConfiguration postrollSlot = new TemporalSlotConfiguration("curly", adConstants.ADUNIT_POSTROLL(), video.getDuration() / 1000);
adRequestConfiguration.addSlotConfiguration(postrollSlot);
// Add overlay
Log.v(TAG, "Adding temporal slot for overlays");
TemporalSlotConfiguration overlaySlot = new TemporalSlotConfiguration("shemp", adConstants.ADUNIT_OVERLAY(), 8);
adRequestConfiguration.addSlotConfiguration(overlaySlot);
}
});
freeWheelController.enable();
}
use of tv.freewheel.ad.request.config.VideoAssetConfiguration in project android-player-samples by BrightcoveOS.
the class MainActivity method setupFreeWheel.
private void setupFreeWheel() {
// change this to new FrameLayout based constructor.
FreeWheelController freeWheelController = new FreeWheelController(this, brightcoveVideoView, eventEmitter);
// configure your own IAdManager or supply connection information
freeWheelController.setAdURL("http://demo.v.fwmrm.net/");
freeWheelController.setAdNetworkId(90750);
freeWheelController.setProfile("3pqa_android");
/*
* Choose one of these to determine the ad policy (basically server or client).
* - 3pqa_section - uses FW server rules - always returns a preroll and a postroll. It should return whatever midroll slots you request though.
* - 3pqa_section_nocbp - returns the slots that you request.
*/
// freeWheelController.setSiteSectionId("3pqa_section");
freeWheelController.setSiteSectionId("3pqa_section_nocbp");
eventEmitter.on(FreeWheelEventType.SHOW_DISPLAY_ADS, new EventListener() {
@Override
public void processEvent(Event event) {
@SuppressWarnings("unchecked") List<ISlot> slots = (List<ISlot>) event.properties.get(FreeWheelController.AD_SLOTS_KEY);
ViewGroup adView = (ViewGroup) findViewById(R.id.ad_frame);
// Clean out any previous display ads
for (int i = 0; i < adView.getChildCount(); i++) {
adView.removeViewAt(i);
}
for (ISlot slot : slots) {
adView.addView(slot.getBase());
slot.play();
}
}
});
eventEmitter.on(FreeWheelEventType.WILL_SUBMIT_AD_REQUEST, new EventListener() {
@Override
public void processEvent(Event event) {
Video video = (Video) event.properties.get(Event.VIDEO);
IAdContext adContext = (IAdContext) event.properties.get(FreeWheelController.AD_CONTEXT_KEY);
IConstants adConstants = adContext.getConstants();
AdRequestConfiguration adRequestConfiguration = (AdRequestConfiguration) event.properties.get(FreeWheelController.AD_REQUEST_CONFIGURATION_KEY);
// This overrides what the plugin does by default for setVideoAsset() which is to pass in currentVideo.getId().
VideoAssetConfiguration fwVideoAssetConfiguration = new VideoAssetConfiguration("3pqa_video", adConstants.ID_TYPE_CUSTOM(), // FW uses their duration as seconds; Android is in milliseconds
video.getDuration() / 1000, adConstants.VIDEO_ASSET_DURATION_TYPE_EXACT(), adConstants.VIDEO_ASSET_AUTO_PLAY_TYPE_ATTENDED());
adRequestConfiguration.setVideoAssetConfiguration(fwVideoAssetConfiguration);
NonTemporalSlotConfiguration companionSlot = new NonTemporalSlotConfiguration("300x250slot", null, 300, 250);
companionSlot.setCompanionAcceptance(true);
adRequestConfiguration.addSlotConfiguration(companionSlot);
// Add preroll
Log.v(TAG, "Adding temporal slot for prerolls");
TemporalSlotConfiguration prerollSlot = new TemporalSlotConfiguration("larry", adConstants.ADUNIT_PREROLL(), 0);
adRequestConfiguration.addSlotConfiguration(prerollSlot);
// Add midroll
Log.v(TAG, "Adding temporal slot for midrolls: duration = " + brightcoveVideoView.getDuration());
int midrollCount = 4;
int segmentLength = (brightcoveVideoView.getDuration() / 1000) / (midrollCount + 1);
TemporalSlotConfiguration midrollSlot;
for (int i = 0; i < midrollCount; i++) {
midrollSlot = new TemporalSlotConfiguration("moe" + i, adConstants.ADUNIT_MIDROLL(), segmentLength * (i + 1));
adRequestConfiguration.addSlotConfiguration(midrollSlot);
}
// Add postroll
Log.v(TAG, "Adding temporal slot for postrolls");
TemporalSlotConfiguration postrollSlot = new TemporalSlotConfiguration("curly", adConstants.ADUNIT_POSTROLL(), video.getDuration() / 1000);
adRequestConfiguration.addSlotConfiguration(postrollSlot);
// Add overlay
Log.v(TAG, "Adding temporal slot for overlays");
TemporalSlotConfiguration overlaySlot = new TemporalSlotConfiguration("shemp", adConstants.ADUNIT_OVERLAY(), 8);
adRequestConfiguration.addSlotConfiguration(overlaySlot);
}
});
freeWheelController.enable();
}
Aggregations