-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18b9304
commit 258fff4
Showing
14 changed files
with
492 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.