Skip to content

Commit

Permalink
Publish SurfaceControl demo
Browse files Browse the repository at this point in the history
Issue: #677
Issue: #5428
PiperOrigin-RevId: 270466031
  • Loading branch information
andrewlewis authored and ojw28 committed Sep 21, 2019
1 parent 18b9304 commit 258fff4
Show file tree
Hide file tree
Showing 14 changed files with 492 additions and 2 deletions.
6 changes: 4 additions & 2 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Bypass sniffing in `ProgressiveMediaPeriod` in case a single extractor is
provided ([#6325](https://github.com/google/ExoPlayer/issues/6325)).
* Surface information provided by methods `isHardwareAccelerated`,
`isSoftwareOnly` and `isVendor` added in Android Q in `MediaCodecInfo` class
`isSoftwareOnly` and `isVendor` added in Android 10 in `MediaCodecInfo` class
([#5839](https://github.com/google/ExoPlayer/issues/5839)).
* Update `DefaultTrackSelector` to apply a viewport constraint for the default
display by default.
Expand All @@ -33,7 +33,7 @@
`SourceInfoRefreshListener` anymore. Instead make it accessible through
`Player.getCurrentManifest()` and `Timeline.Window.manifest`. Also rename
`SourceInfoRefreshListener` to `MediaSourceCaller`.
* Set `compileSdkVersion` to 29 to use Android Q APIs.
* Set `compileSdkVersion` to 29 to use Android 10 APIs.
* Add `enable` and `disable` methods to `MediaSource` to improve resource
management in playlists.
* Text selection logic:
Expand All @@ -59,6 +59,8 @@
* Fix Dolby Vision fallback to AVC and HEVC.
* Add top-level playlist API
([#6161](https://github.com/google/ExoPlayer/issues/6161)).
* Add demo app to show how to use the Android 10 `SurfaceControl` API with
ExoPlayer ([#677](https://github.com/google/ExoPlayer/issues/677)).

### 2.10.5 (2019-09-20) ###

Expand Down
21 changes: 21 additions & 0 deletions demos/surface/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# ExoPlayer SurfaceControl demo

This app demonstrates how to use the [SurfaceControl][] API to redirect video
output from ExoPlayer between different views or off-screen. `SurfaceControl`
is new in Android 10, so the app requires `minSdkVersion` 29.

The app layout has a grid of `SurfaceViews`. Initially video is output to one
of the views. Tap a `SurfaceView` to move video output to it. You can also tap
the buttons at the top of the activity to move video output off-screen, to a
full-screen `SurfaceView` or to a new activity.

When using `SurfaceControl`, the `MediaCodec` always has the same surface
attached to it, which can be freely 'reparented' to any `SurfaceView` (or
off-screen) without any interruptions to playback. This works better than
calling `MediaCodec.setOutputSurface` to change the output surface of the codec
because `MediaCodec` does not re-render its last frame when that method is
called, and because you can move output off-screen easily (`setOutputSurface`
can't take a `null` surface, so the player has to use a `DummySurface`, which
doesn't handle protected output on all devices).

[SurfaceControl]: https://developer.android.com/reference/android/view/SurfaceControl
51 changes: 51 additions & 0 deletions demos/surface/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// 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.
apply from: '../../constants.gradle'
apply plugin: 'com.android.application'

android {
compileSdkVersion project.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
versionName project.ext.releaseVersion
versionCode project.ext.releaseVersionCode
minSdkVersion 29
targetSdkVersion 29
}

buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}

lintOptions {
// This demo app does not have translations.
disable 'MissingTranslation'
}
}

dependencies {
implementation project(modulePrefix + 'library-core')
implementation project(modulePrefix + 'library-ui')
implementation project(modulePrefix + 'library-dash')
implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion
}
41 changes: 41 additions & 0 deletions demos/surface/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.exoplayer2.surfacedemo">
<uses-sdk/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/application_name">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="com.google.android.exoplayer.surfacedemo.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="http"/>
<data android:scheme="https"/>
<data android:scheme="content"/>
<data android:scheme="asset"/>
<data android:scheme="file"/>
</intent-filter>
</activity>
</application>
</manifest>
Loading

0 comments on commit 258fff4

Please sign in to comment.