Java Code Examples for com.google.android.exoplayer2.Player#EventListener

The following examples show how to use com.google.android.exoplayer2.Player#EventListener . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileViewFragment.java    From lbry-android with MIT License 4 votes vote down vote up
public View onCreateView(@NonNull LayoutInflater inflater,
                         ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_file_view, container, false);

    layoutLoadingState = root.findViewById(R.id.file_view_loading_state);
    layoutNothingAtLocation = root.findViewById(R.id.container_nothing_at_location);
    layoutResolving = root.findViewById(R.id.file_view_loading_container);
    layoutDisplayArea = root.findViewById(R.id.file_view_claim_display_area);
    buttonPublishSomething = root.findViewById(R.id.nothing_at_location_publish_button);

    containerReplyToComment = root.findViewById(R.id.comment_form_reply_to_container);
    textReplyingTo = root.findViewById(R.id.comment_form_replying_to_text);
    textReplyToBody = root.findViewById(R.id.comment_form_reply_to_body);
    buttonClearReplyToComment = root.findViewById(R.id.comment_form_clear_reply_to);

    commentChannelSpinner = root.findViewById(R.id.comment_form_channel_spinner);
    progressLoadingChannels = root.findViewById(R.id.comment_form_channels_loading);
    progressPostComment = root.findViewById(R.id.comment_form_post_progress);
    inputComment = root.findViewById(R.id.comment_form_body);
    textCommentLimit = root.findViewById(R.id.comment_form_text_limit);
    buttonPostComment = root.findViewById(R.id.comment_form_post);
    commentPostAsThumbnail = root.findViewById(R.id.comment_form_thumbnail);
    commentPostAsNoThumbnail = root.findViewById(R.id.comment_form_no_thumbnail);
    commentPostAsAlpha = root.findViewById(R.id.comment_form_thumbnail_alpha);

    inlineChannelCreator = root.findViewById(R.id.container_inline_channel_form_create);
    inlineChannelCreatorInputName = root.findViewById(R.id.inline_channel_form_input_name);
    inlineChannelCreatorInputDeposit = root.findViewById(R.id.inline_channel_form_input_deposit);
    inlineChannelCreatorInlineBalance = root.findViewById(R.id.inline_channel_form_inline_balance_container);
    inlineChannelCreatorInlineBalanceValue = root.findViewById(R.id.inline_channel_form_inline_balance_value);
    inlineChannelCreatorProgress = root.findViewById(R.id.inline_channel_form_create_progress);
    inlineChannelCreatorCancelLink = root.findViewById(R.id.inline_channel_form_cancel_link);
    inlineChannelCreatorCreateButton = root.findViewById(R.id.inline_channel_form_create_button);

    initUi(root);

    fileViewPlayerListener = new Player.EventListener() {
        @Override
        public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
            if (playbackState == Player.STATE_READY) {
                elapsedDuration = MainActivity.appPlayer.getCurrentPosition();
                totalDuration = MainActivity.appPlayer.getDuration() < 0 ? 0 : MainActivity.appPlayer.getDuration();
                if (!playbackStarted) {
                    logPlay(currentUrl, startTimeMillis);
                    playbackStarted = true;
                    isPlaying = true;

                    long lastPosition = loadLastPlaybackPosition();
                    if (lastPosition > -1) {
                        MainActivity.appPlayer.seekTo(lastPosition);
                    }
                }
                renderTotalDuration();
                scheduleElapsedPlayback();
                hideBuffering();

                if (loadingNewClaim) {
                    MainActivity.appPlayer.setPlayWhenReady(true);
                    loadingNewClaim = false;
                }
            } else if (playbackState == Player.STATE_BUFFERING) {
                showBuffering();
            } else {
                hideBuffering();
            }
        }
    };

    return root;
}
 
Example 2
Source File: EventListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
public void add(Player.EventListener listener) {
    listeners.add(listener);
}
 
Example 3
Source File: EventListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onTimelineChanged(Timeline timeline, Object manifest, @Player.TimelineChangeReason int reason) {
    for (Player.EventListener listener : listeners) {
        listener.onTimelineChanged(timeline, manifest, reason);
    }
}
 
Example 4
Source File: EventListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
    for (Player.EventListener listener : listeners) {
        listener.onTracksChanged(trackGroups, trackSelections);
    }
}
 
Example 5
Source File: EventListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onLoadingChanged(boolean isLoading) {
    for (Player.EventListener listener : listeners) {
        listener.onLoadingChanged(isLoading);
    }
}
 
Example 6
Source File: EventListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
    for (Player.EventListener listener : listeners) {
        listener.onPlayerStateChanged(playWhenReady, playbackState);
    }
}
 
Example 7
Source File: EventListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onRepeatModeChanged(@Player.RepeatMode int repeatMode) {
    for (Player.EventListener listener : listeners) {
        listener.onRepeatModeChanged(repeatMode);
    }
}
 
Example 8
Source File: EventListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) {
    for (Player.EventListener listener : listeners) {
        listener.onShuffleModeEnabledChanged(shuffleModeEnabled);
    }
}
 
Example 9
Source File: EventListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onPlayerError(ExoPlaybackException error) {
    for (Player.EventListener listener : listeners) {
        listener.onPlayerError(error);
    }
}
 
Example 10
Source File: EventListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onPositionDiscontinuity(int reason) {
    for (Player.EventListener listener : listeners) {
        listener.onPositionDiscontinuity(reason);
    }
}
 
Example 11
Source File: EventListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
    for (Player.EventListener listener : listeners) {
        listener.onPlaybackParametersChanged(playbackParameters);
    }
}
 
Example 12
Source File: EventListener.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public void onSeekProcessed() {
    for (Player.EventListener listener : listeners) {
        listener.onSeekProcessed();
    }
}
 
Example 13
Source File: EqualizedExoPlayer.java    From Jockey with Apache License 2.0 4 votes vote down vote up
@Override
public void addListener(Player.EventListener listener) {
    mExoPlayer.addListener(listener);
}
 
Example 14
Source File: EqualizedExoPlayer.java    From Jockey with Apache License 2.0 4 votes vote down vote up
@Override
public void removeListener(Player.EventListener listener) {
    mExoPlayer.removeListener(listener);
}
 
Example 15
Source File: ProviderTvPlayer.java    From xipl with Apache License 2.0 2 votes vote down vote up
/**
 * Adds listeners for eventual callbacks
 *
 * @param listener the given listener for callbacks.
 */
public void addListener(Player.EventListener listener) {
    player.addListener(listener);
}