Search in sources :

Example 1 with BrightcoveMediaController

use of com.brightcove.player.mediacontroller.BrightcoveMediaController 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_activity_main);
    brightcoveVideoView = (BrightcoveVideoView) findViewById(R.id.brightcove_video_view);
    mediaController = new BrightcoveMediaController(brightcoveVideoView);
    brightcoveVideoView.setMediaController(mediaController);
    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();
    // Remove the HLS_URL field from the catalog request to allow
    // midrolls to work.  Midrolls don't work with HLS due to
    // seeking bugs in the Android OS.
    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.findPlaylistByReferenceID("stitch", options, new PlaylistListener() {

        public void onPlaylist(Playlist playlist) {
            brightcoveVideoView.addAll(playlist.getVideos());
        }

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

Example 2 with BrightcoveMediaController

use of com.brightcove.player.mediacontroller.BrightcoveMediaController in project android-player-samples by BrightcoveOS.

the class MainActivity method initMediaController.

public void initMediaController(final BaseVideoView brightcoveVideoView) {
    if (BrightcoveMediaController.checkTvMode(this)) {
        // Use this method to verify if we're running in Android TV
        brightcoveVideoView.setMediaController(new BrightcoveMediaController(brightcoveVideoView, R.layout.my_tv_media_controller));
    } else {
        brightcoveVideoView.setMediaController(new BrightcoveMediaController(brightcoveVideoView, R.layout.my_media_controller));
    }
    initButtons(brightcoveVideoView);
    // This event is sent by the BrightcovePlayer Activity when the onConfigurationChanged has been called.
    brightcoveVideoView.getEventEmitter().on(EventType.CONFIGURATION_CHANGED, new EventListener() {

        @Override
        public void processEvent(Event event) {
            initButtons(brightcoveVideoView);
        }
    });
}
Also used : Event(com.brightcove.player.event.Event) EventListener(com.brightcove.player.event.EventListener) BrightcoveMediaController(com.brightcove.player.mediacontroller.BrightcoveMediaController)

Example 3 with BrightcoveMediaController

use of com.brightcove.player.mediacontroller.BrightcoveMediaController 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 BrightcoveExoPlayerVideoView before
    // entering the superclass. This allows for some stock video player lifecycle
    // management.
    setContentView(R.layout.ima_activity_main);
    brightcoveVideoView = (BrightcoveExoPlayerVideoView) findViewById(R.id.brightcove_video_view);
    final BrightcoveMediaController mediaController = new BrightcoveMediaController(brightcoveVideoView);
    // Add "Ad Markers" where the Ads Manager says ads will appear.
    mediaController.addListener(GoogleIMAEventType.ADS_MANAGER_LOADED, new EventListener() {

        @Override
        public void processEvent(Event event) {
            AdsManager manager = (AdsManager) event.properties.get("adsManager");
            List<Float> cuepoints = manager.getAdCuePoints();
            for (int i = 0; i < cuepoints.size(); i++) {
                Float cuepoint = cuepoints.get(i);
                mediaController.getBrightcoveSeekBar().addMarker((int) (cuepoint * DateUtils.SECOND_IN_MILLIS));
            }
        }
    });
    brightcoveVideoView.setMediaController(mediaController);
    super.onCreate(savedInstanceState);
    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) ArrayList(java.util.ArrayList) Catalog(com.brightcove.player.media.Catalog) BrightcoveMediaController(com.brightcove.player.mediacontroller.BrightcoveMediaController) AdsManager(com.google.ads.interactivemedia.v3.api.AdsManager) Video(com.brightcove.player.model.Video) Event(com.brightcove.player.event.Event) ArrayList(java.util.ArrayList) List(java.util.List) EventListener(com.brightcove.player.event.EventListener) VideoListener(com.brightcove.player.media.VideoListener)

Aggregations

BrightcoveMediaController (com.brightcove.player.mediacontroller.BrightcoveMediaController)3 Event (com.brightcove.player.event.Event)2 EventListener (com.brightcove.player.event.EventListener)2 Catalog (com.brightcove.player.media.Catalog)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 PlaylistListener (com.brightcove.player.media.PlaylistListener)1 VideoListener (com.brightcove.player.media.VideoListener)1 Playlist (com.brightcove.player.model.Playlist)1 Video (com.brightcove.player.model.Video)1 AdsManager (com.google.ads.interactivemedia.v3.api.AdsManager)1 List (java.util.List)1