Search in sources :

Example 11 with Video

use of com.brightcove.player.model.Video in project android-player-samples by BrightcoveOS.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ima_activity_main);
    eventEmitter = brightcoveVideoView.getEventEmitter();
    // Use a procedural abstraction to setup the Google IMA SDK via the plugin.
    setupGoogleIMA();
    Map<String, String> options = new HashMap<String, String>();
    List<String> values = new ArrayList<String>(Arrays.asList(VideoFields.DEFAULT_FIELDS));
    values.remove(VideoFields.HLS_URL);
    options.put("video_fields", StringUtil.join(values, ","));
    Catalog catalog = new Catalog("ErQk9zUeDVLIp8Dc7aiHKq8hDMgkv5BFU7WGshTc-hpziB3BuYh28A..");
    catalog.findVideoByReferenceID("shark", new VideoListener() {

        public void onVideo(Video video) {
            brightcoveVideoView.add(video);
            // Auto play: the GoogleIMAComponent will postpone
            // playback until the Ad Rules are loaded.
            brightcoveVideoView.start();
        }

        public void onError(String error) {
            Log.e(TAG, error);
        }
    });
}
Also used : HashMap(java.util.HashMap) Video(com.brightcove.player.model.Video) ArrayList(java.util.ArrayList) VideoListener(com.brightcove.player.media.VideoListener) Catalog(com.brightcove.player.media.Catalog)

Example 12 with Video

use of com.brightcove.player.model.Video in project android-player-samples by BrightcoveOS.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    // When extending the BrightcovePlayer, we must assign the BrightcoveVideoView
    // before entering the superclass. This allows for some stock video player lifecycle
    // management.
    setContentView(R.layout.freewheel_activity_main);
    brightcoveVideoView = (BrightcoveVideoView) findViewById(R.id.brightcove_video_view);
    super.onCreate(savedInstanceState);
    adFrame = (FrameLayout) findViewById(R.id.ad_frame);
    eventEmitter = brightcoveVideoView.getEventEmitter();
    setupFreeWheel();
    setupWidevine();
    Catalog catalog = new Catalog("FqicLlYykdimMML7pj65Gi8IHl8EVReWMJh6rLDcTjTMqdb5ay_xFA..");
    catalog.findVideoByID("2142114984001", new VideoListener() {

        @Override
        public void onVideo(Video video) {
            brightcoveVideoView.add(video);
            brightcoveVideoView.start();
        }

        @Override
        public void onError(String error) {
            Log.e(TAG, error);
        }
    });
}
Also used : Video(com.brightcove.player.model.Video) VideoListener(com.brightcove.player.media.VideoListener) Catalog(com.brightcove.player.media.Catalog)

Example 13 with Video

use of com.brightcove.player.model.Video in project android-player-samples by BrightcoveOS.

the class MainActivity method setupFreeWheel.

private void setupFreeWheel() {
    //change this to new FrameLayout based constructor.
    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();
            // This overrides what the plugin does by default for setVideoAsset() which is to pass in currentVideo.getId().
            // video ID
            adContext.setVideoAsset(// video ID
            "3pqa_video", // FW uses their duration as seconds; Android is in milliseconds
            video.getDuration() / 1000, // location
            null, // auto play type
            adConstants.VIDEO_ASSET_AUTO_PLAY_TYPE_ATTENDED(), // a random number
            (int) Math.floor(Math.random() * Integer.MAX_VALUE), // setting networkId for 0 as it's the default value for this method
            0, // type of video ID passed (customer created or FW issued)
            adConstants.ID_TYPE_CUSTOM(), // fallback ID
            0, // duration type
            adConstants.VIDEO_ASSET_DURATION_TYPE_EXACT());
            adContext.addSiteSectionNonTemporalSlot("300x250slot", null, 300, 250, null, true, null, null);
            // Add preroll
            Log.v(TAG, "Adding temporal slot for prerolls");
            adContext.addTemporalSlot("larry", "PREROLL", 0, null, 0, 0, null, null, 0);
            // Add midroll
            Log.v(TAG, "Adding temporal slot for midrolls");
            int midrollCount = 1;
            int segmentLength = (video.getDuration() / 1000) / (midrollCount + 1);
            for (int i = 0; i < midrollCount; i++) {
                adContext.addTemporalSlot("moe" + i, "MIDROLL", segmentLength * (i + 1), null, 0, 0, null, null, 0);
            }
            // Add postroll
            Log.v(TAG, "Adding temporal slot for postrolls");
            adContext.addTemporalSlot("curly", "POSTROLL", video.getDuration() / 1000, null, 0, 0, null, null, 0);
            // Add overlay
            Log.v(TAG, "Adding temporal slot for overlays");
            adContext.addTemporalSlot("shemp", "OVERLAY", 8, null, 0, 0, null, null, 0);
        }
    });
    freeWheelController.enable();
}
Also used : IConstants(tv.freewheel.ad.interfaces.IConstants) IAdContext(tv.freewheel.ad.interfaces.IAdContext) FreeWheelController(com.brightcove.freewheel.controller.FreeWheelController) ViewGroup(android.view.ViewGroup) Video(com.brightcove.player.model.Video) Event(com.brightcove.player.event.Event) List(java.util.List) EventListener(com.brightcove.player.event.EventListener) ISlot(tv.freewheel.ad.interfaces.ISlot)

Example 14 with Video

use of com.brightcove.player.model.Video in project android-player-samples by BrightcoveOS.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    // When extending the BrightcovePlayer, we must assign the BrightcoveVideoView before
    // entering the superclass. This allows for some stock video player lifecycle
    // management.  Establish the video object and use it's event emitter to get important
    // notifications and to control logging.
    setContentView(R.layout.ima_widevine_activity_main);
    brightcoveVideoView = (BrightcoveVideoView) findViewById(R.id.brightcove_video_view);
    super.onCreate(savedInstanceState);
    eventEmitter = brightcoveVideoView.getEventEmitter();
    // Use a procedural abstraction to setup the Google IMA SDK via the plugin and establish
    // a playlist listener object for our sample video: the Potter Puppet show.
    setupGoogleIMA();
    // Initialize the widevine plugin.
    setupWidevine();
    // Create the catalog object which will start and play the video.
    Catalog catalog = new Catalog("FqicLlYykdimMML7pj65Gi8IHl8EVReWMJh6rLDcTjTMqdb5ay_xFA..");
    catalog.findVideoByID("2223563028001", new VideoListener() {

        @Override
        public void onError(String error) {
            Log.e(TAG, error);
        }

        @Override
        public void onVideo(Video video) {
            brightcoveVideoView.add(video);
            brightcoveVideoView.start();
        }
    });
}
Also used : Video(com.brightcove.player.model.Video) VideoListener(com.brightcove.player.media.VideoListener) Catalog(com.brightcove.player.media.Catalog)

Example 15 with Video

use of com.brightcove.player.model.Video in project android-player-samples by BrightcoveOS.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    // When extending the BrightcovePlayer, we must assign the BrightcoveVideoView before
    // entering the superclass. This allows for some stock video player lifecycle
    // management.
    setContentView(R.layout.activity_main);
    brightcoveVideoView = (BrightcoveVideoView) findViewById(R.id.brightcove_video_view);
    super.onCreate(savedInstanceState);
    eventEmitter = brightcoveVideoView.getEventEmitter();
    // Use a procedural abstraction to setup the Google IMA SDK via the plugin.
    setupGoogleIMA();
    // Initialize the widevine plugin.
    setupWidevine();
    // Create the catalog object which will start and play the video.
    Catalog catalog = new Catalog("FqicLlYykdimMML7pj65Gi8IHl8EVReWMJh6rLDcTjTMqdb5ay_xFA..");
    catalog.findVideoByID("2142114984001", new VideoListener() {

        @Override
        public void onVideo(Video video) {
            brightcoveVideoView.add(video);
            // Auto play: the GoogleIMAComponent will postpone
            // playback until the Ad Rules are loaded.
            brightcoveVideoView.start();
        }

        public void onError(String error) {
            Log.e(TAG, error);
        }
    });
}
Also used : Video(com.brightcove.player.model.Video) VideoListener(com.brightcove.player.media.VideoListener) Catalog(com.brightcove.player.media.Catalog)

Aggregations

Video (com.brightcove.player.model.Video)26 Catalog (com.brightcove.player.edge.Catalog)8 VideoListener (com.brightcove.player.edge.VideoListener)8 Catalog (com.brightcove.player.media.Catalog)7 VideoListener (com.brightcove.player.media.VideoListener)7 ViewGroup (android.view.ViewGroup)6 Event (com.brightcove.player.event.Event)6 EventListener (com.brightcove.player.event.EventListener)6 List (java.util.List)6 EventEmitter (com.brightcove.player.event.EventEmitter)5 FreeWheelController (com.brightcove.freewheel.controller.FreeWheelController)4 IAdContext (tv.freewheel.ad.interfaces.IAdContext)4 IConstants (tv.freewheel.ad.interfaces.IConstants)4 ISlot (tv.freewheel.ad.interfaces.ISlot)4 View (android.view.View)3 VideoView (android.widget.VideoView)2 VMAPComponent (com.brightcove.vmap.VMAPComponent)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 WidevinePlugin (com.brightcove.drm.widevine.WidevinePlugin)1