PierfrancescoSoffritti / android-youtube-player

YouTube Player library for Android and Chromecast, stable and customizable.
https://pierfrancescosoffritti.github.io/android-youtube-player/
MIT License
3.38k stars 758 forks source link

Backword and forwarding video Enable In CustomActions Button #700

Open abhihasabe opened 3 years ago

abhihasabe commented 3 years ago

I have created CustomActions Button for forwarding and Backword video, but how to do this fun.

Please check given code,

private void initYouTubePlayerView() { initPlayerMenu();

    getLifecycle().addObserver(youTubePlayerView);

    youTubePlayerView.addYouTubePlayerListener(new AbstractYouTubePlayerListener() {
        @Override
        public void onReady(@NonNull YouTubePlayer youTubePlayer) {
            YouTubePlayerUtils.loadOrCueVideo(
                    youTubePlayer,
                    getLifecycle(),
                    videoIds,
                    0f
            );
            addCustomActionsToPlayer();
            //addFullScreenListenerToPlayer();
            //setPlayNextVideoButtonClickListener(youTubePlayer);
        }
    });
}

private void addCustomActionsToPlayer() { youTubePlayerView.getPlayerUiController().showCustomAction1(true); youTubePlayerView.getPlayerUiController().showCustomAction2(true); Drawable customAction1Icon = ContextCompat.getDrawable(this, R.drawable.ic_fast_rewind_white_24dp); Drawable customAction2Icon = ContextCompat.getDrawable(this, R.drawable.ic_fast_forward_white_24dp); assert customAction1Icon != null; assert customAction2Icon != null;

    youTubePlayerView.getPlayerUiController().setCustomAction1(customAction1Icon, view ->
            Toast.makeText(this, "custom action1 clicked", Toast.LENGTH_SHORT).show());

    youTubePlayerView.getPlayerUiController().setCustomAction2(customAction2Icon, view ->
            Toast.makeText(this, "custom action1 clicked", Toast.LENGTH_SHORT).show());
}
Mak35988 commented 2 years ago

chalega nhi yaar