-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 5-rtsp-barebones-issue-8994 - added (unofficial) - illustrates the fatal error in the RTSP library that causes the app to force close, as described by ExoPlayer issue 8994 google/ExoPlayer#8994
- Loading branch information
1 parent
2b4a077
commit 6b43260
Showing
12 changed files
with
242 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
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 project.ext.minSdkVersion | ||
targetSdkVersion project.ext.targetSdkVersion | ||
} | ||
|
||
buildTypes { | ||
release { | ||
shrinkResources true | ||
minifyEnabled true | ||
proguardFiles = [ | ||
"proguard-rules.txt", | ||
getDefaultProguardFile('proguard-android.txt') | ||
] | ||
} | ||
debug { | ||
jniDebuggable = true | ||
} | ||
} | ||
|
||
lintOptions { | ||
disable 'GoogleAppIndexingWarning','MissingTranslation' | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation 'com.google.android.exoplayer:exoplayer-core:' + project.ext.releaseVersion // (1.3 MB) https://mvnrepository.com/artifact/com.google.android.exoplayer/exoplayer-core?repo=scijava-public | ||
implementation 'com.google.android.exoplayer:exoplayer-rtsp:' + project.ext.releaseVersion // (101 KB) https://mvnrepository.com/artifact/com.google.android.exoplayer/exoplayer-rtsp?repo=scijava-public | ||
implementation 'com.google.android.exoplayer:exoplayer-ui:' + project.ext.releaseVersion // (433 KB) https://mvnrepository.com/artifact/com.google.android.exoplayer/exoplayer-ui?repo=scijava-public | ||
} | ||
|
||
apply plugin: 'com.google.android.gms.strict-version-matcher-plugin' |
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,3 @@ | ||
-keep class com.google.android.exoplayer2.** { *; } | ||
|
||
-dontwarn com.google.android.exoplayer2.** |
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) 2020 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" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
package="com.google.android.exoplayer2.rtspdemo_8994"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET"/> | ||
|
||
<application | ||
android:label="@string/application_name" | ||
android:icon="@mipmap/ic_launcher" | ||
android:largeHeap="true" | ||
android:allowBackup="false"> | ||
|
||
<activity | ||
android:name=".MainActivity" | ||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
|
||
</application> | ||
|
||
</manifest> |
119 changes: 119 additions & 0 deletions
119
...es-issue-8994/src/main/java/com/google/android/exoplayer2/rtspdemo_8994/MainActivity.java
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,119 @@ | ||
/* | ||
* Copyright (C) 2020 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.rtspdemo_8994; | ||
|
||
import android.app.Activity; | ||
import android.os.Bundle; | ||
import com.google.android.exoplayer2.MediaItem; | ||
import com.google.android.exoplayer2.Player; | ||
import com.google.android.exoplayer2.SimpleExoPlayer; | ||
import com.google.android.exoplayer2.source.MediaSource; | ||
import com.google.android.exoplayer2.source.rtsp.RtspMediaSource; | ||
import com.google.android.exoplayer2.ui.PlayerView; | ||
import com.google.android.exoplayer2.util.Util; | ||
|
||
public final class MainActivity extends Activity { | ||
|
||
private static final String TAG = "MainActivity"; | ||
|
||
private static final String RTSP_MEDIA_URI = "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_175k.mov"; | ||
private static final String RTSP_MIME_TYPE = "application/x-rtsp"; | ||
|
||
private PlayerView playerView; | ||
private SimpleExoPlayer player; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.main_activity); | ||
playerView = findViewById(R.id.player_view); | ||
} | ||
|
||
@Override | ||
public void onStart() { | ||
super.onStart(); | ||
if (Util.SDK_INT > 23) { | ||
initializePlayer(); | ||
if (playerView != null) { | ||
playerView.onResume(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void onResume() { | ||
super.onResume(); | ||
if (Util.SDK_INT <= 23 || player == null) { | ||
initializePlayer(); | ||
if (playerView != null) { | ||
playerView.onResume(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void onPause() { | ||
super.onPause(); | ||
if (Util.SDK_INT <= 23) { | ||
if (playerView != null) { | ||
playerView.onPause(); | ||
} | ||
releasePlayer(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onStop() { | ||
super.onStop(); | ||
if (Util.SDK_INT > 23) { | ||
if (playerView != null) { | ||
playerView.onPause(); | ||
} | ||
releasePlayer(); | ||
} | ||
} | ||
|
||
private void initializePlayer() { | ||
SimpleExoPlayer player = new SimpleExoPlayer.Builder(getApplicationContext()).build(); | ||
|
||
MediaItem mediaItem = new MediaItem.Builder().setUri(RTSP_MEDIA_URI).setMimeType(RTSP_MIME_TYPE).build(); | ||
MediaSource mediaSource = (MediaSource) new RtspMediaSource.Factory().createMediaSource(mediaItem); | ||
|
||
if (playerView != null) { | ||
playerView.setPlayer(player); | ||
} | ||
|
||
// this configuration causes fatal error in RTSP library!! | ||
player.setRepeatMode(Player.REPEAT_MODE_ALL); | ||
|
||
player.setPlayWhenReady(true); | ||
player.setMediaSource(mediaSource); | ||
player.prepare(); | ||
|
||
this.player = player; | ||
} | ||
|
||
private void releasePlayer() { | ||
if (playerView != null) { | ||
playerView.setPlayer(null); | ||
} | ||
|
||
if (player != null) { | ||
player.release(); | ||
player = null; | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
5-rtsp-barebones-issue-8994/src/main/res/layout/main_activity.xml
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,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright (C) 2020 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. | ||
--> | ||
<FrameLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:keepScreenOn="true"> | ||
|
||
<com.google.android.exoplayer2.ui.PlayerView | ||
android:id="@+id/player_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" /> | ||
|
||
</FrameLayout> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.77 KB
5-rtsp-barebones-issue-8994/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.32 KB
5-rtsp-barebones-issue-8994/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.5 KB
5-rtsp-barebones-issue-8994/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> | ||
|
||
<string name="application_name">ExoPlayer</string> | ||
|
||
</resources> |
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