Java Code Examples for com.google.android.exoplayer2.PlayerMessage#blockUntilDelivered()

The following examples show how to use com.google.android.exoplayer2.PlayerMessage#blockUntilDelivered() . 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: ExoFFmpegPlayer.java    From DanDanPlayForAndroid with MIT License 6 votes vote down vote up
private void onSurfaceSizeChanged(int width, int height) {
    List<PlayerMessage> messages = new ArrayList<>();
    Point size = new Point(width, height);

    for (Renderer renderer : renderers) {
        if (renderer.getTrackType() == C.TRACK_TYPE_VIDEO) {
            messages.add(createMessage(renderer).setType(Constant.MSG_SURFACE_SIZE_CHANGED).setPayload(size).send());
        }
    }

    try {
        for (PlayerMessage message : messages){
            message.blockUntilDelivered();
        }
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}
 
Example 2
Source File: ExoFFmpegPlayer.java    From DanDanPlayForAndroid with MIT License 6 votes vote down vote up
private void onPlayReleased() {

        List<PlayerMessage> messages = new ArrayList<>();

        for (Renderer renderer : renderers) {
            messages.add(createMessage(renderer).setType(MSG_PLAY_RELEASED).send());
        }

        try {
            for (PlayerMessage message : messages){
                message.blockUntilDelivered();
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
 
Example 3
Source File: ExoMediaPlayer.java    From ExoMedia with Apache License 2.0 6 votes vote down vote up
/**
 * This was pulled from the <i>Deprecated</i> ExoPlayerImpl#blockingSendMessages method
 *
 * @param messages The messages
 */
protected void blockingSendMessages(List<PlayerMessage> messages) {
    boolean wasInterrupted = false;
    for (PlayerMessage message : messages) {
        boolean blockMessage = true;
        while (blockMessage) {
            try {
                message.blockUntilDelivered();
                blockMessage = false;
            } catch (InterruptedException e) {
                wasInterrupted = true;
            }
        }
    }

    if (wasInterrupted) {
        // Restore the interrupted status.
        Thread.currentThread().interrupt();
    }
}