Commit 56ff2ef5 by hoangtc Committed by Oliver Woodman

Add getPlaybackLooper() to ExoPlayer v2.

A few components in ExoPlayer requires playback looper to operate (such as:
DrmSessionManager#acquireSession), so this CL add back getPlaybackLooper()
to facilitate such cases.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=159416012
parent d9ea8f71
......@@ -284,6 +284,13 @@ public interface ExoPlayer {
int REPEAT_MODE_ALL = 2;
/**
* Gets the {@link Looper} associated with the playback thread.
*
* @return The {@link Looper} associated with the playback thread.
*/
Looper getPlaybackLooper();
/**
* Register a listener to receive events from the player. The listener's methods will be called on
* the thread that was used to construct the player. However, if the thread used to construct the
* player does not have a {@link Looper}, then the listener will be called on the main thread.
......
......@@ -107,6 +107,11 @@ import java.util.concurrent.CopyOnWriteArraySet;
}
@Override
public Looper getPlaybackLooper() {
return internalPlayer.getPlaybackLooper();
}
@Override
public void addListener(EventListener listener) {
listeners.add(listener);
}
......
......@@ -17,6 +17,7 @@ package com.google.android.exoplayer2;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.os.Process;
import android.os.SystemClock;
......@@ -270,6 +271,10 @@ import java.io.IOException;
internalPlaybackThread.quit();
}
public Looper getPlaybackLooper() {
return internalPlaybackThread.getLooper();
}
// MediaSource.Listener implementation.
@Override
......
......@@ -481,6 +481,11 @@ public class SimpleExoPlayer implements ExoPlayer {
// ExoPlayer implementation
@Override
public Looper getPlaybackLooper() {
return player.getPlaybackLooper();
}
@Override
public void addListener(EventListener listener) {
player.addListener(listener);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment