diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index 564864fb40..381bebf05e 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -74,8 +74,6 @@
cache.
* Library restructuring:
* `DebugTextViewHelper` moved from `ui` package to `util` package.
- * Spherical UI components moved from `video.spherical` package to
- `ui.spherical` package, and made package private.
* Remove deprecated symbols:
* Remove `ExoPlayerFactory` methods. Use `SimpleExoPlayer.Builder`
instead.
diff --git a/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java b/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java
index 8dccc9e8b2..b6a52381d7 100644
--- a/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java
+++ b/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java
@@ -48,8 +48,6 @@ import com.google.android.exoplayer2.util.ListenerSet;
import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util;
-import com.google.android.exoplayer2.video.VideoFrameMetadataListener;
-import com.google.android.exoplayer2.video.spherical.CameraMotionListener;
import com.google.android.gms.cast.CastStatusCodes;
import com.google.android.gms.cast.MediaInfo;
import com.google.android.gms.cast.MediaQueueItem;
@@ -653,22 +651,6 @@ public final class CastPlayer extends BasePlayer {
return 1;
}
- /** This method is not supported and does nothing. */
- @Override
- public void setVideoFrameMetadataListener(VideoFrameMetadataListener listener) {}
-
- /** This method is not supported and does nothing. */
- @Override
- public void clearVideoFrameMetadataListener(VideoFrameMetadataListener listener) {}
-
- /** This method is not supported and does nothing. */
- @Override
- public void setCameraMotionListener(CameraMotionListener listener) {}
-
- /** This method is not supported and does nothing. */
- @Override
- public void clearCameraMotionListener(CameraMotionListener listener) {}
-
/** This method is not supported and does nothing. */
@Override
public void clearVideoSurface() {}
diff --git a/library/common/src/main/java/com/google/android/exoplayer2/Player.java b/library/common/src/main/java/com/google/android/exoplayer2/Player.java
index 76b1b02f03..66121aa6ee 100644
--- a/library/common/src/main/java/com/google/android/exoplayer2/Player.java
+++ b/library/common/src/main/java/com/google/android/exoplayer2/Player.java
@@ -35,9 +35,7 @@ import com.google.android.exoplayer2.text.TextOutput;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
import com.google.android.exoplayer2.util.ExoFlags;
import com.google.android.exoplayer2.util.Util;
-import com.google.android.exoplayer2.video.VideoFrameMetadataListener;
import com.google.android.exoplayer2.video.VideoListener;
-import com.google.android.exoplayer2.video.spherical.CameraMotionListener;
import com.google.common.base.Objects;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
@@ -1686,40 +1684,6 @@ public interface Player {
*/
float getVolume();
- /**
- * Sets a listener to receive video frame metadata events.
- *
- *
This method is intended to be called by the same component that sets the {@link Surface}
- * onto which video will be rendered. If using ExoPlayer's standard UI components, this method
- * should not be called directly from application code.
- *
- * @param listener The listener.
- */
- void setVideoFrameMetadataListener(VideoFrameMetadataListener listener);
-
- /**
- * Clears the listener which receives video frame metadata events if it matches the one passed.
- * Else does nothing.
- *
- * @param listener The listener to clear.
- */
- void clearVideoFrameMetadataListener(VideoFrameMetadataListener listener);
-
- /**
- * Sets a listener of camera motion events.
- *
- * @param listener The listener.
- */
- void setCameraMotionListener(CameraMotionListener listener);
-
- /**
- * Clears the listener which receives camera motion events if it matches the one passed. Else does
- * nothing.
- *
- * @param listener The listener to clear.
- */
- void clearCameraMotionListener(CameraMotionListener listener);
-
/**
* Clears any {@link Surface}, {@link SurfaceHolder}, {@link SurfaceView} or {@link TextureView}
* currently set on the player.
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java
index dcd91f3323..10ae1a413c 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java
@@ -52,8 +52,6 @@ import com.google.android.exoplayer2.util.HandlerWrapper;
import com.google.android.exoplayer2.util.ListenerSet;
import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.util.Util;
-import com.google.android.exoplayer2.video.VideoFrameMetadataListener;
-import com.google.android.exoplayer2.video.spherical.CameraMotionListener;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.Collections;
@@ -1010,22 +1008,6 @@ import java.util.concurrent.CopyOnWriteArraySet;
return 1;
}
- /** This method is not supported and does nothing. */
- @Override
- public void setVideoFrameMetadataListener(VideoFrameMetadataListener listener) {}
-
- /** This method is not supported and does nothing. */
- @Override
- public void clearVideoFrameMetadataListener(VideoFrameMetadataListener listener) {}
-
- /** This method is not supported and does nothing. */
- @Override
- public void setCameraMotionListener(CameraMotionListener listener) {}
-
- /** This method is not supported and does nothing. */
- @Override
- public void clearCameraMotionListener(CameraMotionListener listener) {}
-
/** This method is not supported and does nothing. */
@Override
public void clearVideoSurface() {}
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java b/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java
index 4e5aecf88a..60a29f678c 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java
@@ -15,12 +15,23 @@
*/
package com.google.android.exoplayer2;
+import static com.google.android.exoplayer2.Renderer.MSG_SET_AUDIO_ATTRIBUTES;
+import static com.google.android.exoplayer2.Renderer.MSG_SET_AUDIO_SESSION_ID;
+import static com.google.android.exoplayer2.Renderer.MSG_SET_AUX_EFFECT_INFO;
+import static com.google.android.exoplayer2.Renderer.MSG_SET_CAMERA_MOTION_LISTENER;
+import static com.google.android.exoplayer2.Renderer.MSG_SET_SCALING_MODE;
+import static com.google.android.exoplayer2.Renderer.MSG_SET_SKIP_SILENCE_ENABLED;
+import static com.google.android.exoplayer2.Renderer.MSG_SET_VIDEO_FRAME_METADATA_LISTENER;
+import static com.google.android.exoplayer2.Renderer.MSG_SET_VIDEO_OUTPUT;
+import static com.google.android.exoplayer2.Renderer.MSG_SET_VOLUME;
+
import android.content.Context;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
import android.media.AudioFormat;
import android.media.AudioTrack;
import android.media.MediaCodec;
+import android.media.MediaFormat;
import android.os.Handler;
import android.os.Looper;
import android.view.Surface;
@@ -66,6 +77,7 @@ import com.google.android.exoplayer2.video.VideoFrameMetadataListener;
import com.google.android.exoplayer2.video.VideoListener;
import com.google.android.exoplayer2.video.VideoRendererEventListener;
import com.google.android.exoplayer2.video.spherical.CameraMotionListener;
+import com.google.android.exoplayer2.video.spherical.SphericalGLSurfaceView;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -586,6 +598,7 @@ public class SimpleExoPlayer extends BasePlayer
private final Context applicationContext;
private final ExoPlayerImpl player;
private final ComponentListener componentListener;
+ private final FrameMetadataListener frameMetadataListener;
private final CopyOnWriteArraySet videoListeners;
private final CopyOnWriteArraySet audioListeners;
private final CopyOnWriteArraySet textOutputs;
@@ -605,6 +618,7 @@ public class SimpleExoPlayer extends BasePlayer
@Nullable private Object videoOutput;
@Nullable private Surface ownedSurface;
@Nullable private SurfaceHolder surfaceHolder;
+ @Nullable private SphericalGLSurfaceView sphericalGLSurfaceView;
private boolean surfaceHolderSurfaceIsVideoOutput;
@Nullable private TextureView textureView;
@C.VideoScalingMode private int videoScalingMode;
@@ -664,6 +678,7 @@ public class SimpleExoPlayer extends BasePlayer
skipSilenceEnabled = builder.skipSilenceEnabled;
detachSurfaceTimeoutMs = builder.detachSurfaceTimeoutMs;
componentListener = new ComponentListener();
+ frameMetadataListener = new FrameMetadataListener();
videoListeners = new CopyOnWriteArraySet<>();
audioListeners = new CopyOnWriteArraySet<>();
textOutputs = new CopyOnWriteArraySet<>();
@@ -739,12 +754,15 @@ public class SimpleExoPlayer extends BasePlayer
deviceInfo = createDeviceInfo(streamVolumeManager);
currentMediaMetadata = MediaMetadata.EMPTY;
- sendRendererMessage(C.TRACK_TYPE_AUDIO, Renderer.MSG_SET_AUDIO_SESSION_ID, audioSessionId);
- sendRendererMessage(C.TRACK_TYPE_VIDEO, Renderer.MSG_SET_AUDIO_SESSION_ID, audioSessionId);
- sendRendererMessage(C.TRACK_TYPE_AUDIO, Renderer.MSG_SET_AUDIO_ATTRIBUTES, audioAttributes);
- sendRendererMessage(C.TRACK_TYPE_VIDEO, Renderer.MSG_SET_SCALING_MODE, videoScalingMode);
+ sendRendererMessage(C.TRACK_TYPE_AUDIO, MSG_SET_AUDIO_SESSION_ID, audioSessionId);
+ sendRendererMessage(C.TRACK_TYPE_VIDEO, MSG_SET_AUDIO_SESSION_ID, audioSessionId);
+ sendRendererMessage(C.TRACK_TYPE_AUDIO, MSG_SET_AUDIO_ATTRIBUTES, audioAttributes);
+ sendRendererMessage(C.TRACK_TYPE_VIDEO, MSG_SET_SCALING_MODE, videoScalingMode);
+ sendRendererMessage(C.TRACK_TYPE_AUDIO, MSG_SET_SKIP_SILENCE_ENABLED, skipSilenceEnabled);
sendRendererMessage(
- C.TRACK_TYPE_AUDIO, Renderer.MSG_SET_SKIP_SILENCE_ENABLED, skipSilenceEnabled);
+ C.TRACK_TYPE_VIDEO, MSG_SET_VIDEO_FRAME_METADATA_LISTENER, frameMetadataListener);
+ sendRendererMessage(
+ C.TRACK_TYPE_CAMERA_MOTION, MSG_SET_CAMERA_MOTION_LISTENER, frameMetadataListener);
} finally {
constructorFinished.open();
}
@@ -804,7 +822,7 @@ public class SimpleExoPlayer extends BasePlayer
public void setVideoScalingMode(@C.VideoScalingMode int videoScalingMode) {
verifyApplicationThread();
this.videoScalingMode = videoScalingMode;
- sendRendererMessage(C.TRACK_TYPE_VIDEO, Renderer.MSG_SET_SCALING_MODE, videoScalingMode);
+ sendRendererMessage(C.TRACK_TYPE_VIDEO, MSG_SET_SCALING_MODE, videoScalingMode);
}
@Override
@@ -874,19 +892,18 @@ public class SimpleExoPlayer extends BasePlayer
if (surfaceView instanceof VideoDecoderOutputBufferRenderer) {
removeSurfaceCallbacks();
setVideoOutputInternal(surfaceView);
- // Although we won't use the surface directly as the video output, still use the holder to
- // query the surface size, to be informed in changes to the size via componentListener, and
- // for equality checking in clearVideoSurfaceHolder.
- surfaceHolderSurfaceIsVideoOutput = false;
- surfaceHolder = surfaceView.getHolder();
- surfaceHolder.addCallback(componentListener);
- Surface surface = surfaceHolder.getSurface();
- if (surface != null && surface.isValid()) {
- Rect surfaceSize = surfaceHolder.getSurfaceFrame();
- maybeNotifySurfaceSizeChanged(surfaceSize.width(), surfaceSize.height());
- } else {
- maybeNotifySurfaceSizeChanged(/* width= */ 0, /* height= */ 0);
- }
+ setNonVideoOutputSurfaceHolderInternal(surfaceView.getHolder());
+ } else if (surfaceView instanceof SphericalGLSurfaceView) {
+ removeSurfaceCallbacks();
+ sphericalGLSurfaceView = (SphericalGLSurfaceView) surfaceView;
+ player
+ .createMessage(frameMetadataListener)
+ .setType(FrameMetadataListener.MSG_SET_SPHERICAL_SURFACE_VIEW)
+ .setPayload(sphericalGLSurfaceView)
+ .send();
+ sphericalGLSurfaceView.addVideoSurfaceListener(componentListener);
+ setVideoOutputInternal(sphericalGLSurfaceView.getVideoSurface());
+ setNonVideoOutputSurfaceHolderInternal(surfaceView.getHolder());
} else {
setVideoSurfaceHolder(surfaceView == null ? null : surfaceView.getHolder());
}
@@ -964,7 +981,7 @@ public class SimpleExoPlayer extends BasePlayer
}
if (!Util.areEqual(this.audioAttributes, audioAttributes)) {
this.audioAttributes = audioAttributes;
- sendRendererMessage(C.TRACK_TYPE_AUDIO, Renderer.MSG_SET_AUDIO_ATTRIBUTES, audioAttributes);
+ sendRendererMessage(C.TRACK_TYPE_AUDIO, MSG_SET_AUDIO_ATTRIBUTES, audioAttributes);
streamVolumeManager.setStreamType(Util.getStreamTypeForAudioUsage(audioAttributes.usage));
analyticsCollector.onAudioAttributesChanged(audioAttributes);
for (AudioListener audioListener : audioListeners) {
@@ -1003,8 +1020,8 @@ public class SimpleExoPlayer extends BasePlayer
initializeKeepSessionIdAudioTrack(audioSessionId);
}
this.audioSessionId = audioSessionId;
- sendRendererMessage(C.TRACK_TYPE_AUDIO, Renderer.MSG_SET_AUDIO_SESSION_ID, audioSessionId);
- sendRendererMessage(C.TRACK_TYPE_VIDEO, Renderer.MSG_SET_AUDIO_SESSION_ID, audioSessionId);
+ sendRendererMessage(C.TRACK_TYPE_AUDIO, MSG_SET_AUDIO_SESSION_ID, audioSessionId);
+ sendRendererMessage(C.TRACK_TYPE_VIDEO, MSG_SET_AUDIO_SESSION_ID, audioSessionId);
analyticsCollector.onAudioSessionIdChanged(audioSessionId);
for (AudioListener audioListener : audioListeners) {
audioListener.onAudioSessionIdChanged(audioSessionId);
@@ -1019,7 +1036,7 @@ public class SimpleExoPlayer extends BasePlayer
@Override
public void setAuxEffectInfo(AuxEffectInfo auxEffectInfo) {
verifyApplicationThread();
- sendRendererMessage(C.TRACK_TYPE_AUDIO, Renderer.MSG_SET_AUX_EFFECT_INFO, auxEffectInfo);
+ sendRendererMessage(C.TRACK_TYPE_AUDIO, MSG_SET_AUX_EFFECT_INFO, auxEffectInfo);
}
@Override
@@ -1059,8 +1076,7 @@ public class SimpleExoPlayer extends BasePlayer
return;
}
this.skipSilenceEnabled = skipSilenceEnabled;
- sendRendererMessage(
- C.TRACK_TYPE_AUDIO, Renderer.MSG_SET_SKIP_SILENCE_ENABLED, skipSilenceEnabled);
+ sendRendererMessage(C.TRACK_TYPE_AUDIO, MSG_SET_SKIP_SILENCE_ENABLED, skipSilenceEnabled);
notifySkipSilenceEnabledChanged();
}
@@ -1173,8 +1189,11 @@ public class SimpleExoPlayer extends BasePlayer
public void setVideoFrameMetadataListener(VideoFrameMetadataListener listener) {
verifyApplicationThread();
videoFrameMetadataListener = listener;
- sendRendererMessage(
- C.TRACK_TYPE_VIDEO, Renderer.MSG_SET_VIDEO_FRAME_METADATA_LISTENER, listener);
+ player
+ .createMessage(frameMetadataListener)
+ .setType(FrameMetadataListener.MSG_SET_VIDEO_FRAME_METADATA_LISTENER)
+ .setPayload(listener)
+ .send();
}
@Override
@@ -1183,16 +1202,22 @@ public class SimpleExoPlayer extends BasePlayer
if (videoFrameMetadataListener != listener) {
return;
}
- sendRendererMessage(
- C.TRACK_TYPE_VIDEO, Renderer.MSG_SET_VIDEO_FRAME_METADATA_LISTENER, /* payload= */ null);
+ player
+ .createMessage(frameMetadataListener)
+ .setType(FrameMetadataListener.MSG_SET_VIDEO_FRAME_METADATA_LISTENER)
+ .setPayload(null)
+ .send();
}
@Override
public void setCameraMotionListener(CameraMotionListener listener) {
verifyApplicationThread();
cameraMotionListener = listener;
- sendRendererMessage(
- C.TRACK_TYPE_CAMERA_MOTION, Renderer.MSG_SET_CAMERA_MOTION_LISTENER, listener);
+ player
+ .createMessage(frameMetadataListener)
+ .setType(FrameMetadataListener.MSG_SET_CAMERA_MOTION_LISTENER)
+ .setPayload(listener)
+ .send();
}
@Override
@@ -1201,8 +1226,11 @@ public class SimpleExoPlayer extends BasePlayer
if (cameraMotionListener != listener) {
return;
}
- sendRendererMessage(
- C.TRACK_TYPE_CAMERA_MOTION, Renderer.MSG_SET_CAMERA_MOTION_LISTENER, /* payload= */ null);
+ player
+ .createMessage(frameMetadataListener)
+ .setType(FrameMetadataListener.MSG_SET_CAMERA_MOTION_LISTENER)
+ .setPayload(null)
+ .send();
}
@Override
@@ -1832,6 +1860,15 @@ public class SimpleExoPlayer extends BasePlayer
// Internal methods.
private void removeSurfaceCallbacks() {
+ if (sphericalGLSurfaceView != null) {
+ player
+ .createMessage(frameMetadataListener)
+ .setType(FrameMetadataListener.MSG_SET_SPHERICAL_SURFACE_VIEW)
+ .setPayload(null)
+ .send();
+ sphericalGLSurfaceView.removeVideoSurfaceListener(componentListener);
+ sphericalGLSurfaceView = null;
+ }
if (textureView != null) {
if (textureView.getSurfaceTextureListener() != componentListener) {
Log.w(TAG, "SurfaceTextureListener already unset or replaced.");
@@ -1861,7 +1898,7 @@ public class SimpleExoPlayer extends BasePlayer
messages.add(
player
.createMessage(renderer)
- .setType(Renderer.MSG_SET_VIDEO_OUTPUT)
+ .setType(MSG_SET_VIDEO_OUTPUT)
.setPayload(videoOutput)
.send());
}
@@ -1891,6 +1928,30 @@ public class SimpleExoPlayer extends BasePlayer
this.videoOutput = videoOutput;
}
+ /**
+ * Sets the holder of the surface that will be displayed to the user, but which should
+ * not be the output for video renderers. This case occurs when video frames need to be
+ * rendered to an intermediate surface (which is not the one held by the provided holder).
+ *
+ * @param nonVideoOutputSurfaceHolder The holder of the surface that will eventually be displayed
+ * to the user.
+ */
+ private void setNonVideoOutputSurfaceHolderInternal(SurfaceHolder nonVideoOutputSurfaceHolder) {
+ // Although we won't use the view's surface directly as the video output, still use the holder
+ // to query the surface size, to be informed in changes to the size via componentListener, and
+ // for equality checking in clearVideoSurfaceHolder.
+ surfaceHolderSurfaceIsVideoOutput = false;
+ surfaceHolder = nonVideoOutputSurfaceHolder;
+ surfaceHolder.addCallback(componentListener);
+ Surface surface = surfaceHolder.getSurface();
+ if (surface != null && surface.isValid()) {
+ Rect surfaceSize = surfaceHolder.getSurfaceFrame();
+ maybeNotifySurfaceSizeChanged(surfaceSize.width(), surfaceSize.height());
+ } else {
+ maybeNotifySurfaceSizeChanged(/* width= */ 0, /* height= */ 0);
+ }
+ }
+
private void maybeNotifySurfaceSizeChanged(int width, int height) {
if (width != surfaceWidth || height != surfaceHeight) {
surfaceWidth = width;
@@ -1904,7 +1965,7 @@ public class SimpleExoPlayer extends BasePlayer
private void sendVolumeToRenderers() {
float scaledVolume = audioVolume * audioFocusManager.getVolumeMultiplier();
- sendRendererMessage(C.TRACK_TYPE_AUDIO, Renderer.MSG_SET_VOLUME, scaledVolume);
+ sendRendererMessage(C.TRACK_TYPE_AUDIO, MSG_SET_VOLUME, scaledVolume);
}
@SuppressWarnings("SuspiciousMethodCalls")
@@ -2026,6 +2087,7 @@ public class SimpleExoPlayer extends BasePlayer
MetadataOutput,
SurfaceHolder.Callback,
TextureView.SurfaceTextureListener,
+ SphericalGLSurfaceView.VideoSurfaceListener,
AudioFocusManager.PlayerControl,
AudioBecomingNoisyManager.EventListener,
StreamVolumeManager.Listener,
@@ -2232,6 +2294,18 @@ public class SimpleExoPlayer extends BasePlayer
// Do nothing.
}
+ // SphericalGLSurfaceView.VideoSurfaceListener
+
+ @Override
+ public void onVideoSurfaceCreated(Surface surface) {
+ setVideoOutputInternal(surface);
+ }
+
+ @Override
+ public void onVideoSurfaceDestroyed(Surface surface) {
+ setVideoOutputInternal(/* videoOutput= */ null);
+ }
+
// AudioFocusManager.PlayerControl implementation
@Override
@@ -2315,4 +2389,84 @@ public class SimpleExoPlayer extends BasePlayer
updateWakeAndWifiLock();
}
}
+
+ /** Listeners that are called on the playback thread. */
+ private static final class FrameMetadataListener
+ implements VideoFrameMetadataListener, CameraMotionListener, PlayerMessage.Target {
+
+ public static final int MSG_SET_VIDEO_FRAME_METADATA_LISTENER =
+ Renderer.MSG_SET_VIDEO_FRAME_METADATA_LISTENER;
+ public static final int MSG_SET_CAMERA_MOTION_LISTENER =
+ Renderer.MSG_SET_CAMERA_MOTION_LISTENER;
+ public static final int MSG_SET_SPHERICAL_SURFACE_VIEW = Renderer.MSG_CUSTOM_BASE;
+
+ @Nullable private VideoFrameMetadataListener videoFrameMetadataListener;
+ @Nullable private CameraMotionListener cameraMotionListener;
+ @Nullable private VideoFrameMetadataListener internalVideoFrameMetadataListener;
+ @Nullable private CameraMotionListener internalCameraMotionListener;
+
+ @Override
+ public void handleMessage(int messageType, @Nullable Object payload) {
+ switch (messageType) {
+ case MSG_SET_VIDEO_FRAME_METADATA_LISTENER:
+ videoFrameMetadataListener = (VideoFrameMetadataListener) payload;
+ break;
+ case MSG_SET_CAMERA_MOTION_LISTENER:
+ cameraMotionListener = (CameraMotionListener) payload;
+ break;
+ case MSG_SET_SPHERICAL_SURFACE_VIEW:
+ SphericalGLSurfaceView surfaceView = (SphericalGLSurfaceView) payload;
+ if (surfaceView == null) {
+ internalVideoFrameMetadataListener = null;
+ internalCameraMotionListener = null;
+ } else {
+ internalVideoFrameMetadataListener = surfaceView.getVideoFrameMetadataListener();
+ internalCameraMotionListener = surfaceView.getCameraMotionListener();
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ // VideoFrameMetadataListener
+
+ @Override
+ public void onVideoFrameAboutToBeRendered(
+ long presentationTimeUs,
+ long releaseTimeNs,
+ Format format,
+ @Nullable MediaFormat mediaFormat) {
+ if (internalVideoFrameMetadataListener != null) {
+ internalVideoFrameMetadataListener.onVideoFrameAboutToBeRendered(
+ presentationTimeUs, releaseTimeNs, format, mediaFormat);
+ }
+ if (videoFrameMetadataListener != null) {
+ videoFrameMetadataListener.onVideoFrameAboutToBeRendered(
+ presentationTimeUs, releaseTimeNs, format, mediaFormat);
+ }
+ }
+
+ // CameraMotionListener
+
+ @Override
+ public void onCameraMotion(long timeUs, float[] rotation) {
+ if (internalCameraMotionListener != null) {
+ internalCameraMotionListener.onCameraMotion(timeUs, rotation);
+ }
+ if (cameraMotionListener != null) {
+ cameraMotionListener.onCameraMotion(timeUs, rotation);
+ }
+ }
+
+ @Override
+ public void onCameraMotionReset() {
+ if (internalCameraMotionListener != null) {
+ internalCameraMotionListener.onCameraMotionReset();
+ }
+ if (cameraMotionListener != null) {
+ cameraMotionListener.onCameraMotionReset();
+ }
+ }
+ }
}
diff --git a/library/common/src/main/java/com/google/android/exoplayer2/video/VideoFrameMetadataListener.java b/library/core/src/main/java/com/google/android/exoplayer2/video/VideoFrameMetadataListener.java
similarity index 100%
rename from library/common/src/main/java/com/google/android/exoplayer2/video/VideoFrameMetadataListener.java
rename to library/core/src/main/java/com/google/android/exoplayer2/video/VideoFrameMetadataListener.java
diff --git a/library/common/src/main/java/com/google/android/exoplayer2/video/spherical/CameraMotionListener.java b/library/core/src/main/java/com/google/android/exoplayer2/video/spherical/CameraMotionListener.java
similarity index 100%
rename from library/common/src/main/java/com/google/android/exoplayer2/video/spherical/CameraMotionListener.java
rename to library/core/src/main/java/com/google/android/exoplayer2/video/spherical/CameraMotionListener.java
diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/FrameRotationQueue.java b/library/core/src/main/java/com/google/android/exoplayer2/video/spherical/FrameRotationQueue.java
similarity index 98%
rename from library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/FrameRotationQueue.java
rename to library/core/src/main/java/com/google/android/exoplayer2/video/spherical/FrameRotationQueue.java
index 8299ecd000..84bdcb7277 100644
--- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/FrameRotationQueue.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/video/spherical/FrameRotationQueue.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.google.android.exoplayer2.ui.spherical;
+package com.google.android.exoplayer2.video.spherical;
import android.opengl.Matrix;
import com.google.android.exoplayer2.util.TimedValueQueue;
diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/OrientationListener.java b/library/core/src/main/java/com/google/android/exoplayer2/video/spherical/OrientationListener.java
similarity index 98%
rename from library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/OrientationListener.java
rename to library/core/src/main/java/com/google/android/exoplayer2/video/spherical/OrientationListener.java
index 1a52202efc..d35c7531b1 100644
--- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/OrientationListener.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/video/spherical/OrientationListener.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.google.android.exoplayer2.ui.spherical;
+package com.google.android.exoplayer2.video.spherical;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/Projection.java b/library/core/src/main/java/com/google/android/exoplayer2/video/spherical/Projection.java
similarity index 99%
rename from library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/Projection.java
rename to library/core/src/main/java/com/google/android/exoplayer2/video/spherical/Projection.java
index 5c7dc4fa15..357299a5d2 100644
--- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/Projection.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/video/spherical/Projection.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.google.android.exoplayer2.ui.spherical;
+package com.google.android.exoplayer2.video.spherical;
import androidx.annotation.IntDef;
import com.google.android.exoplayer2.C;
diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/ProjectionDecoder.java b/library/core/src/main/java/com/google/android/exoplayer2/video/spherical/ProjectionDecoder.java
similarity index 97%
rename from library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/ProjectionDecoder.java
rename to library/core/src/main/java/com/google/android/exoplayer2/video/spherical/ProjectionDecoder.java
index 576b47c2f0..9f2e1e697e 100644
--- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/ProjectionDecoder.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/video/spherical/ProjectionDecoder.java
@@ -13,15 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.google.android.exoplayer2.ui.spherical;
+package com.google.android.exoplayer2.video.spherical;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
-import com.google.android.exoplayer2.ui.spherical.Projection.Mesh;
-import com.google.android.exoplayer2.ui.spherical.Projection.SubMesh;
import com.google.android.exoplayer2.util.ParsableBitArray;
import com.google.android.exoplayer2.util.ParsableByteArray;
import com.google.android.exoplayer2.util.Util;
+import com.google.android.exoplayer2.video.spherical.Projection.Mesh;
+import com.google.android.exoplayer2.video.spherical.Projection.SubMesh;
import java.util.ArrayList;
import java.util.zip.Inflater;
diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/ProjectionRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/video/spherical/ProjectionRenderer.java
similarity index 99%
rename from library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/ProjectionRenderer.java
rename to library/core/src/main/java/com/google/android/exoplayer2/video/spherical/ProjectionRenderer.java
index 1f0f2017d6..4ba5dcca08 100644
--- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/ProjectionRenderer.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/video/spherical/ProjectionRenderer.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.google.android.exoplayer2.ui.spherical;
+package com.google.android.exoplayer2.video.spherical;
import static com.google.android.exoplayer2.util.GlUtil.checkGlError;
diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/SceneRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/video/spherical/SceneRenderer.java
similarity index 98%
rename from library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/SceneRenderer.java
rename to library/core/src/main/java/com/google/android/exoplayer2/video/spherical/SceneRenderer.java
index 2b6e3f1ead..dcc15d1fed 100644
--- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/SceneRenderer.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/video/spherical/SceneRenderer.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.google.android.exoplayer2.ui.spherical;
+package com.google.android.exoplayer2.video.spherical;
import static com.google.android.exoplayer2.util.GlUtil.checkGlError;
@@ -28,7 +28,6 @@ import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.GlUtil;
import com.google.android.exoplayer2.util.TimedValueQueue;
import com.google.android.exoplayer2.video.VideoFrameMetadataListener;
-import com.google.android.exoplayer2.video.spherical.CameraMotionListener;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicBoolean;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/SphericalGLSurfaceView.java b/library/core/src/main/java/com/google/android/exoplayer2/video/spherical/SphericalGLSurfaceView.java
similarity index 80%
rename from library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/SphericalGLSurfaceView.java
rename to library/core/src/main/java/com/google/android/exoplayer2/video/spherical/SphericalGLSurfaceView.java
index 0dd9466f48..5f1610350a 100644
--- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/SphericalGLSurfaceView.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/video/spherical/SphericalGLSurfaceView.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.google.android.exoplayer2.ui.spherical;
+package com.google.android.exoplayer2.video.spherical;
import android.content.Context;
import android.graphics.PointF;
@@ -36,9 +36,10 @@ import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.annotation.VisibleForTesting;
import com.google.android.exoplayer2.C;
-import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Util;
+import com.google.android.exoplayer2.video.VideoFrameMetadataListener;
+import java.util.concurrent.CopyOnWriteArrayList;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
@@ -54,6 +55,16 @@ import javax.microedition.khronos.opengles.GL10;
*/
public final class SphericalGLSurfaceView extends GLSurfaceView {
+ /** Listener for the {@link Surface} to which video frames should be rendered. */
+ public interface VideoSurfaceListener {
+
+ /** Called when the {@link Surface} to which video frames should be rendered is created. */
+ void onVideoSurfaceCreated(Surface surface);
+
+ /** Called when the {@link Surface} to which video frames should be rendered is destroyed. */
+ void onVideoSurfaceDestroyed(Surface surface);
+ }
+
// Arbitrary vertical field of view.
private static final int FIELD_OF_VIEW_DEGREES = 90;
private static final float Z_NEAR = 0.1f;
@@ -64,6 +75,7 @@ public final class SphericalGLSurfaceView extends GLSurfaceView {
/* package */ static final float UPRIGHT_ROLL = (float) Math.PI;
+ private final CopyOnWriteArrayList videoSurfaceListeners;
private final SensorManager sensorManager;
@Nullable private final Sensor orientationSensor;
private final OrientationListener orientationListener;
@@ -72,7 +84,6 @@ public final class SphericalGLSurfaceView extends GLSurfaceView {
private final SceneRenderer scene;
@Nullable private SurfaceTexture surfaceTexture;
@Nullable private Surface surface;
- @Nullable private Player player;
private boolean useSensorRotation;
private boolean isStarted;
private boolean isOrientationListenerRegistered;
@@ -83,6 +94,7 @@ public final class SphericalGLSurfaceView extends GLSurfaceView {
public SphericalGLSurfaceView(Context context, @Nullable AttributeSet attributeSet) {
super(context, attributeSet);
+ videoSurfaceListeners = new CopyOnWriteArrayList<>();
mainHandler = new Handler(Looper.getMainLooper());
// Configure sensors and touch.
@@ -115,6 +127,43 @@ public final class SphericalGLSurfaceView extends GLSurfaceView {
setOnTouchListener(touchTracker);
}
+ /**
+ * Adds a {@link VideoSurfaceListener}.
+ *
+ * @param listener The listener to add.
+ */
+ public void addVideoSurfaceListener(VideoSurfaceListener listener) {
+ videoSurfaceListeners.add(listener);
+ }
+
+ /**
+ * Removes a {@link VideoSurfaceListener}.
+ *
+ * @param listener The listener to remove.
+ */
+ public void removeVideoSurfaceListener(VideoSurfaceListener listener) {
+ videoSurfaceListeners.remove(listener);
+ }
+
+ /**
+ * Returns the {@link Surface} to which video frames should be rendered, or {@code null} if it has
+ * not been created.
+ */
+ @Nullable
+ public Surface getVideoSurface() {
+ return surface;
+ }
+
+ /** Returns the {@link VideoFrameMetadataListener} that should be registered during playback. */
+ public VideoFrameMetadataListener getVideoFrameMetadataListener() {
+ return scene;
+ }
+
+ /** Returns the {@link CameraMotionListener} that should be registered during playback. */
+ public CameraMotionListener getCameraMotionListener() {
+ return scene;
+ }
+
/**
* Sets the default stereo mode. If the played video doesn't contain a stereo mode the default one
* is used.
@@ -125,26 +174,6 @@ public final class SphericalGLSurfaceView extends GLSurfaceView {
scene.setDefaultStereoMode(stereoMode);
}
- /** Sets the {@link Player} to use. */
- public void setPlayer(@Nullable Player newPlayer) {
- if (newPlayer == player) {
- return;
- }
- if (player != null) {
- if (surface != null) {
- player.clearVideoSurface(surface);
- }
- player.clearVideoFrameMetadataListener(scene);
- player.clearCameraMotionListener(scene);
- }
- player = newPlayer;
- if (this.player != null) {
- player.setVideoFrameMetadataListener(scene);
- player.setCameraMotionListener(scene);
- player.setVideoSurface(surface);
- }
- }
-
/** Sets whether to use the orientation sensor for rotation (if available). */
public void setUseSensorRotation(boolean useSensorRotation) {
this.useSensorRotation = useSensorRotation;
@@ -173,14 +202,15 @@ public final class SphericalGLSurfaceView extends GLSurfaceView {
// Post to make sure we occur in order with any onSurfaceTextureAvailable calls.
mainHandler.post(
() -> {
- if (surface != null) {
- if (player != null) {
- player.clearVideoSurface(surface);
+ @Nullable Surface oldSurface = surface;
+ if (oldSurface != null) {
+ for (VideoSurfaceListener videoSurfaceListener : videoSurfaceListeners) {
+ videoSurfaceListener.onVideoSurfaceDestroyed(oldSurface);
}
- releaseSurface(surfaceTexture, surface);
- surfaceTexture = null;
- surface = null;
}
+ releaseSurface(surfaceTexture, oldSurface);
+ surfaceTexture = null;
+ surface = null;
});
}
@@ -199,15 +229,16 @@ public final class SphericalGLSurfaceView extends GLSurfaceView {
}
// Called on GL thread.
- private void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture) {
+ private void onSurfaceTextureAvailable(SurfaceTexture newSurfaceTexture) {
mainHandler.post(
() -> {
- SurfaceTexture oldSurfaceTexture = this.surfaceTexture;
- Surface oldSurface = this.surface;
- this.surfaceTexture = surfaceTexture;
- this.surface = new Surface(surfaceTexture);
- if (player != null) {
- player.setVideoSurface(surface);
+ @Nullable SurfaceTexture oldSurfaceTexture = surfaceTexture;
+ @Nullable Surface oldSurface = surface;
+ Surface newSurface = new Surface(newSurfaceTexture);
+ surfaceTexture = newSurfaceTexture;
+ surface = newSurface;
+ for (VideoSurfaceListener videoSurfaceListener : videoSurfaceListeners) {
+ videoSurfaceListener.onVideoSurfaceCreated(newSurface);
}
releaseSurface(oldSurfaceTexture, oldSurface);
});
diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/TouchTracker.java b/library/core/src/main/java/com/google/android/exoplayer2/video/spherical/TouchTracker.java
similarity index 99%
rename from library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/TouchTracker.java
rename to library/core/src/main/java/com/google/android/exoplayer2/video/spherical/TouchTracker.java
index 5c5e4d4af8..c159fbee59 100644
--- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/TouchTracker.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/video/spherical/TouchTracker.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.google.android.exoplayer2.ui.spherical;
+package com.google.android.exoplayer2.video.spherical;
import android.content.Context;
import android.graphics.PointF;
diff --git a/library/common/src/main/java/com/google/android/exoplayer2/video/spherical/package-info.java b/library/core/src/main/java/com/google/android/exoplayer2/video/spherical/package-info.java
similarity index 100%
rename from library/common/src/main/java/com/google/android/exoplayer2/video/spherical/package-info.java
rename to library/core/src/main/java/com/google/android/exoplayer2/video/spherical/package-info.java
diff --git a/library/ui/src/test/java/com/google/android/exoplayer2/ui/spherical/FrameRotationQueueTest.java b/library/core/src/test/java/com/google/android/exoplayer2/video/spherical/FrameRotationQueueTest.java
similarity index 98%
rename from library/ui/src/test/java/com/google/android/exoplayer2/ui/spherical/FrameRotationQueueTest.java
rename to library/core/src/test/java/com/google/android/exoplayer2/video/spherical/FrameRotationQueueTest.java
index dfa9c73004..227a827679 100644
--- a/library/ui/src/test/java/com/google/android/exoplayer2/ui/spherical/FrameRotationQueueTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/video/spherical/FrameRotationQueueTest.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.google.android.exoplayer2.ui.spherical;
+package com.google.android.exoplayer2.video.spherical;
import static com.google.common.truth.Truth.assertThat;
diff --git a/library/ui/src/test/java/com/google/android/exoplayer2/ui/spherical/ProjectionDecoderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/video/spherical/ProjectionDecoderTest.java
similarity index 98%
rename from library/ui/src/test/java/com/google/android/exoplayer2/ui/spherical/ProjectionDecoderTest.java
rename to library/core/src/test/java/com/google/android/exoplayer2/video/spherical/ProjectionDecoderTest.java
index 9cdf1727f7..8cabd85fad 100644
--- a/library/ui/src/test/java/com/google/android/exoplayer2/ui/spherical/ProjectionDecoderTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/video/spherical/ProjectionDecoderTest.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.google.android.exoplayer2.ui.spherical;
+package com.google.android.exoplayer2.video.spherical;
import static com.google.common.truth.Truth.assertThat;
diff --git a/library/ui/src/test/java/com/google/android/exoplayer2/ui/spherical/ProjectionTest.java b/library/core/src/test/java/com/google/android/exoplayer2/video/spherical/ProjectionTest.java
similarity index 98%
rename from library/ui/src/test/java/com/google/android/exoplayer2/ui/spherical/ProjectionTest.java
rename to library/core/src/test/java/com/google/android/exoplayer2/video/spherical/ProjectionTest.java
index 3578ae1bb4..1a889bbaa7 100644
--- a/library/ui/src/test/java/com/google/android/exoplayer2/ui/spherical/ProjectionTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/video/spherical/ProjectionTest.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.google.android.exoplayer2.ui.spherical;
+package com.google.android.exoplayer2.video.spherical;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
diff --git a/library/ui/src/test/java/com/google/android/exoplayer2/ui/spherical/TouchTrackerTest.java b/library/core/src/test/java/com/google/android/exoplayer2/video/spherical/TouchTrackerTest.java
similarity index 98%
rename from library/ui/src/test/java/com/google/android/exoplayer2/ui/spherical/TouchTrackerTest.java
rename to library/core/src/test/java/com/google/android/exoplayer2/video/spherical/TouchTrackerTest.java
index 9537c36303..a4965bf92e 100644
--- a/library/ui/src/test/java/com/google/android/exoplayer2/ui/spherical/TouchTrackerTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/video/spherical/TouchTrackerTest.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.google.android.exoplayer2.ui.spherical;
+package com.google.android.exoplayer2.video.spherical;
import static com.google.common.truth.Truth.assertThat;
diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java
index 257d1c9e7a..c635418807 100644
--- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java
+++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java
@@ -62,12 +62,12 @@ import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
import com.google.android.exoplayer2.trackselection.TrackSelectionUtil;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout.ResizeMode;
-import com.google.android.exoplayer2.ui.spherical.SphericalGLSurfaceView;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.ErrorMessageProvider;
import com.google.android.exoplayer2.util.RepeatModeUtil;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoDecoderGLSurfaceView;
+import com.google.android.exoplayer2.video.spherical.SphericalGLSurfaceView;
import com.google.common.collect.ImmutableList;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
@@ -566,8 +566,6 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
if (oldPlayer.isCommandAvailable(COMMAND_SET_VIDEO_SURFACE)) {
if (surfaceView instanceof TextureView) {
oldPlayer.clearVideoTextureView((TextureView) surfaceView);
- } else if (surfaceView instanceof SphericalGLSurfaceView) {
- ((SphericalGLSurfaceView) surfaceView).setPlayer(null);
} else if (surfaceView instanceof SurfaceView) {
oldPlayer.clearVideoSurfaceView((SurfaceView) surfaceView);
}
@@ -587,8 +585,6 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
if (player.isCommandAvailable(COMMAND_SET_VIDEO_SURFACE)) {
if (surfaceView instanceof TextureView) {
player.setVideoTextureView((TextureView) surfaceView);
- } else if (surfaceView instanceof SphericalGLSurfaceView) {
- ((SphericalGLSurfaceView) surfaceView).setPlayer(player);
} else if (surfaceView instanceof SurfaceView) {
player.setVideoSurfaceView((SurfaceView) surfaceView);
}
diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java
index 7f0a0f19ab..3f0872b7a4 100644
--- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java
+++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java
@@ -63,12 +63,12 @@ import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
import com.google.android.exoplayer2.trackselection.TrackSelectionUtil;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout.ResizeMode;
-import com.google.android.exoplayer2.ui.spherical.SphericalGLSurfaceView;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.ErrorMessageProvider;
import com.google.android.exoplayer2.util.RepeatModeUtil;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoDecoderGLSurfaceView;
+import com.google.android.exoplayer2.video.spherical.SphericalGLSurfaceView;
import com.google.common.collect.ImmutableList;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
@@ -570,11 +570,8 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
}
@Nullable Player oldPlayer = this.player;
if (oldPlayer != null) {
- oldPlayer.removeListener(componentListener);
if (surfaceView instanceof TextureView) {
oldPlayer.clearVideoTextureView((TextureView) surfaceView);
- } else if (surfaceView instanceof SphericalGLSurfaceView) {
- ((SphericalGLSurfaceView) surfaceView).setPlayer(null);
} else if (surfaceView instanceof SurfaceView) {
oldPlayer.clearVideoSurfaceView((SurfaceView) surfaceView);
}
@@ -593,8 +590,6 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
if (player.isCommandAvailable(COMMAND_SET_VIDEO_SURFACE)) {
if (surfaceView instanceof TextureView) {
player.setVideoTextureView((TextureView) surfaceView);
- } else if (surfaceView instanceof SphericalGLSurfaceView) {
- ((SphericalGLSurfaceView) surfaceView).setPlayer(player);
} else if (surfaceView instanceof SurfaceView) {
player.setVideoSurfaceView((SurfaceView) surfaceView);
}
diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/SingleTapListener.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/SingleTapListener.java
deleted file mode 100644
index 7328bdfcab..0000000000
--- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/SingleTapListener.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.google.android.exoplayer2.ui.spherical;
-
-import android.view.MotionEvent;
-
-/** Listens tap events on a {@link android.view.View}. */
-public interface SingleTapListener {
- /**
- * Notified when a tap occurs with the up {@link MotionEvent} that triggered it.
- *
- * @param e The up motion event that completed the first tap.
- * @return Whether the event is consumed.
- */
- boolean onSingleTapUp(MotionEvent e);
-}
diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/package-info.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/package-info.java
deleted file mode 100644
index bbbffc7a44..0000000000
--- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/spherical/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-@NonNullApi
-package com.google.android.exoplayer2.ui.spherical;
-
-import com.google.android.exoplayer2.util.NonNullApi;
diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/StubExoPlayer.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/StubExoPlayer.java
index cdac50b4b3..d278e3b3c7 100644
--- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/StubExoPlayer.java
+++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/StubExoPlayer.java
@@ -41,8 +41,6 @@ import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
import com.google.android.exoplayer2.trackselection.TrackSelector;
import com.google.android.exoplayer2.util.Clock;
-import com.google.android.exoplayer2.video.VideoFrameMetadataListener;
-import com.google.android.exoplayer2.video.spherical.CameraMotionListener;
import java.util.List;
/**
@@ -446,26 +444,6 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
throw new UnsupportedOperationException();
}
- @Override
- public void setVideoFrameMetadataListener(VideoFrameMetadataListener listener) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void clearVideoFrameMetadataListener(VideoFrameMetadataListener listener) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setCameraMotionListener(CameraMotionListener listener) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void clearCameraMotionListener(CameraMotionListener listener) {
- throw new UnsupportedOperationException();
- }
-
@Override
public void clearVideoSurface() {
throw new UnsupportedOperationException();