@Override public void deleteVideo(@NonNull Video video) { catalog.deleteVideo(video, new OfflineCallback<Boolean>() { @Override public void onSuccess(Boolean aBoolean) { } @Override public void onFailure(Throwable throwable) { Log.e(TAG, "Error deleting video: ", throwable); } }); } };
/** * Searches the given catalog for this playlist. * * @param catalog reference to the catalog to be searched. * @param listener reference to a listener instance that will be notified when the search is complete. * @throws NullPointerException if the catalog or listener is null. */ public void findPlaylist(@NonNull Catalog catalog, @NonNull PlaylistListener listener) { if (referenceId != null) { catalog.findPlaylistByReferenceID(referenceId, listener); } else if (id != null) { catalog.findPlaylistByID(id, listener); } } }
@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.activity_main); brightcoveVideoView = (BrightcoveExoPlayerVideoView) 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(); // Create the catalog object which will start and play the video. Catalog catalog = new Catalog(brightcoveVideoView.getEventEmitter(), "3303963094001", "BCpkADawqM3zXLtsEM0nAyA_3o3TmZnG6bZTXFmjZ8X_rmFMqlpB78l0aiRELs7MWACf4mYN92qMOLMxfZN6Xr3cQ_0R3G2qBiho3X3Nc2yTv7DH4APQ-EimMJQ3crX0zc0mJMy9CtSqkmli"); catalog.findVideoByID("4283173439001", 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(); } @Override public void onError(String s) { Log.e(TAG, "Could not load video: " + s); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final RecyclerView videoListView = findViewById(R.id.video_list_view); final VideoListAdapter videoListAdapter = new VideoListAdapter(this); videoListView.setAdapter(videoListAdapter); EventEmitter eventEmitter = new EventEmitterImpl(); Catalog catalog = new Catalog(eventEmitter, getString(R.string.account), getString(R.string.policy)); catalog.findPlaylistByReferenceID(getString(R.string.playlistRefId), new PlaylistListener() { @Override public void onPlaylist(Playlist playlist) { videoListAdapter.setVideoList(playlist.getVideos()); } }); }
void getVideo(final OfflineCallback<Video> callback) { final Video result = video; if (video.isOfflinePlaybackAllowed()) { catalog.findOfflineVideoById(video.getId(), new OfflineCallback<Video>() { @Override public void onSuccess(Video offlineVideo) { if (offlineVideo != null) { callback.onSuccess(offlineVideo); } else { callback.onSuccess(video); } } @Override public void onFailure(Throwable throwable) { callback.onSuccess(result); } }); } else { callback.onSuccess(result); } } }
@Override public void rentVideo(@NonNull final Video video) { // Fetch the video object again to avoid using the given video that may have been // changed by previous download. catalog.findVideoByID(video.getId(), new FindVideoListener(video) { @Override public void onVideo(Video newVideo) { MainActivity.this.rentVideo(newVideo); } }); }
@Override public void downloadVideo(@NonNull final Video video) { // bundle has all available captions and audio tracks catalog.getMediaFormatTracksAvailable(video, new MediaDownloadable.MediaFormatListener() { @Override public void onResult(MediaDownloadable mediaDownloadable, Bundle bundle) { BrightcoveDownloadUtil.selectMediaFormatTracksAvailable(mediaDownloadable, bundle); catalog.downloadVideo(video, new OfflineCallback<DownloadStatus>() { @Override public void onSuccess(DownloadStatus downloadStatus) { // Video download started successfully videoListAdapter.notifyVideoChanged(video); } @Override public void onFailure(Throwable throwable) { Log.e(TAG, "Error initializing video download: ", throwable); } }); } }); }
@Override public void resumeVideoDownload(@NonNull Video video) { Log.v(TAG,"Calling resumeVideoDownload."); catalog.resumeVideoDownload(video, new OfflineCallback<Integer>() { @Override public void onSuccess(Integer integer) { // Video download was resumed successfully } @Override public void onFailure(Throwable throwable) { Log.e(TAG, "Error resuming video download: ", throwable); } }); }
@Override public void pauseVideoDownload(@NonNull Video video) { Log.v(TAG,"Calling pauseVideoDownload."); catalog.pauseVideoDownload(video, new OfflineCallback<Integer>() { @Override public void onSuccess(Integer integer) { // Video download was paused successfully } @Override public void onFailure(Throwable throwable) { Log.e(TAG, "Error pausing video download: ", throwable); } }); }
@Override public void onDateSelected(@NonNull Date expiryDate) { long playDuration = video.getDuration(); if (playDuration == 0) { playDuration = DEFAULT_RENTAL_PLAY_DURATION; } catalog.requestRentalLicense(video, expiryDate, playDuration, licenseEventListener); } })
@Override protected void onStart() { super.onStart(); ConnectivityMonitor.getInstance(this).addListener(connectivityListener); catalog.addDownloadEventListener(downloadEventListener); updateVideoList(); }
@Override protected void onPause() { super.onPause(); if (isFinishing()) { ConnectivityMonitor.getInstance(this).removeListener(connectivityListener); catalog.removeDownloadEventListener(downloadEventListener); } }
@Override protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_main); brightcoveVideoView = (BrightcoveExoPlayerVideoView) findViewById(R.id.brightcove_video_view); super.onCreate(savedInstanceState); // Get the event emitter from the SDK and create a catalog request to fetch a video from the // Brightcove Edge service, given a video id, an account id and a policy key. EventEmitter eventEmitter = brightcoveVideoView.getEventEmitter(); Catalog catalog = new Catalog(eventEmitter, getString(R.string.account), getString(R.string.policy)); catalog.findVideoByID(getString(R.string.videoId), 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(); } }); }
@Override public void onFailure(Throwable throwable) { callback.onSuccess(result); } });
@Override public void buyVideo(@NonNull final Video video) { // Fetch the video object again to avoid using the given video that may have been // changed by previous download. catalog.findVideoByID(video.getId(), new FindVideoListener(video) { @Override public void onVideo(Video newVideo) { catalog.requestPurchaseLicense(video, licenseEventListener); } }); }
@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.activity_main); brightcoveVideoView = (BrightcoveExoPlayerVideoView) findViewById(R.id.brightcove_video_view); super.onCreate(savedInstanceState); // Get the event emitter from the SDK and create a catalog request to fetch a video from the // Brightcove Edge service, given a video id, an account id and a policy key. EventEmitter eventEmitter = brightcoveVideoView.getEventEmitter(); Catalog catalog = new Catalog(eventEmitter, getString(R.string.account), getString(R.string.policy)); catalog.findVideoByID(getString(R.string.videoId), 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(); } }); } }
@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.activity_main); brightcoveVideoView = (BrightcoveExoPlayerTextureVideoView) findViewById(R.id.brightcove_video_view); super.onCreate(savedInstanceState); // Get the event emitter from the SDK and create a catalog request to fetch a video from the // Brightcove Edge service, given a video id, an account id and a policy key. EventEmitter eventEmitter = brightcoveVideoView.getEventEmitter(); Catalog catalog = new Catalog(eventEmitter, getString(R.string.account), getString(R.string.policy)); catalog.findVideoByID(getString(R.string.videoId), 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(); } }); } }
@Override @SuppressWarnings("ResourceType") 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.activity_main); brightcoveVideoView = (BrightcoveExoPlayerVideoView) findViewById(R.id.brightcove_video_view); super.onCreate(savedInstanceState); EventEmitter eventEmitter = brightcoveVideoView.getEventEmitter(); Catalog catalog = new Catalog(eventEmitter, getString(R.string.account), getString(R.string.policy)); catalog.findVideoByID(getString(R.string.videoId), new VideoListener() { @Override public void onVideo(Video video) { Video.ProjectionFormat projectionFormat = video.getProjectionFormat(); if (projectionFormat == Video.ProjectionFormat.EQUIRECTANGULAR) { Log.i(TAG, "This is a 360 video"); } brightcoveVideoView.add(video); brightcoveVideoView.start(); } }); //You can also create a 360 video by setting the the projection field on creation as shown below: //Video video = Video.createVideo(VIDEO_URL, VIDEO_TYPE, PROJECTION_FORMAT); }
@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); // *** This method call is optional *** // setupAdMarkers(brightcoveVideoView); super.onCreate(savedInstanceState); eventEmitter = brightcoveVideoView.getEventEmitter(); // Use a procedural abstraction to setup the Google IMA SDK via the plugin. setupGoogleIMA(); Catalog catalog = new Catalog(eventEmitter, getString(R.string.account), getString(R.string.policy)); catalog.findVideoByID(getString(R.string.videoId), 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); } }); }