From f4aa22fa7cfef564be66b7d9792dd5f8ab17e209 Mon Sep 17 00:00:00 2001 From: Tomislav Kordic Date: Mon, 28 Aug 2023 14:08:31 +0200 Subject: [PATCH] Stuck on player playback bug. --- app/build.gradle | 51 +------------------ .../theoplayer/demo/MainActivity.java | 7 ++- automatedtests/build.gradle | 22 +------- .../automatedtests/RenditionChangeTests.java | 14 +++-- .../sdk/muxstats/automatedtests/TestBase.java | 2 +- .../ui/SimplePlayerTestActivity.java | 1 + muxstatssdktheoplayer/build.gradle | 25 +-------- 7 files changed, 21 insertions(+), 101 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 59b27cd..cfe0525 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,14 +20,8 @@ android { versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.support.test.runner.AndroidJUnitRunner" - -<<<<<<< Updated upstream - manifestPlaceholders.theoLicense = "YOUR_THEOPLAYER_LICENSE_HERE" + manifestPlaceholders.theoLicense = "${theo_licence}" } -======= - manifestPlaceholders.theoLicense = "${theo_licence}" - } ->>>>>>> Stashed changes buildTypes { @@ -37,26 +31,6 @@ android { } } sourceSets { - minapi16 { - java.srcDirs = ["./src/no_ads/java"] - res.srcDirs = ["./src/no_ads/res"] - assets.srcDirs = ["./src/no_ads/assets"] - } - minapi21 { - java.srcDirs = ["./src/no_ads/java"] - res.srcDirs = ["./src/no_ads/res"] - assets.srcDirs = ["./src/no_ads/assets"] - } - minapi16ads { - java.srcDirs = ["./src/ads/java"] - res.srcDirs = ["./src/ads/res"] - assets.srcDirs = ["./src/ads/assets"] - } - minapi21ads { - java.srcDirs = ["./src/ads/java"] - res.srcDirs = ["./src/ads/res"] - assets.srcDirs = ["./src/ads/assets"] - } v5 { java.srcDirs = ["./src/no_ads/java"] res.srcDirs = ["./src/no_ads/res"] @@ -67,20 +41,6 @@ android { flavorDimensions "api" productFlavors { - minapi16 { - dimension "api" - } - minapi21 { - dimension "api" - minSdkVersion 21 - } - minapi16ads { - dimension "api" - } - minapi21ads { - dimension "api" - minSdkVersion 21 - } v5 { dimension 'api' minSdkVersion 21 @@ -106,16 +66,7 @@ dependencies { api "org.checkerframework:checker-qual:3.32.0" implementation project(":muxstatssdktheoplayer") - minapi16adsImplementation files("../common_libs/theoplayer-android-dist-56d3a9e5-4252-4bca-b650-180c8f16ce52-2.80.0-minapi16-release.aar") - minapi21adsImplementation files("../common_libs/theoplayer-android-dist-56d3a9e5-4252-4bca-b650-180c8f16ce52-2.80.0-minapi21-release.aar") - minapi16Implementation files("../common_libs/theoplayer-android-dist-56d3a9e5-4252-4bca-b650-180c8f16ce52-2.80.0-minapi16-release.aar") - minapi21Implementation files("../common_libs/theoplayer-android-dist-56d3a9e5-4252-4bca-b650-180c8f16ce52-2.80.0-minapi21-release.aar") - implementation "com.google.code.gson:gson:2.9.1" implementation "androidx.constraintlayout:constraintlayout:2.2.0-alpha09" implementation "androidx.appcompat:appcompat:1.6.1" - minapi16adsImplementation "com.google.ads.interactivemedia.v3:interactivemedia:3.30.0" - minapi16adsImplementation "com.google.android.gms:play-services-ads-identifier:18.0.1" - minapi21adsImplementation "com.google.ads.interactivemedia.v3:interactivemedia:3.30.0" - minapi21adsImplementation "com.google.android.gms:play-services-ads-identifier:18.0.1" } diff --git a/app/src/no_ads/java/com/mux/stats/sdk/muxstats/theoplayer/demo/MainActivity.java b/app/src/no_ads/java/com/mux/stats/sdk/muxstats/theoplayer/demo/MainActivity.java index d1aeb90..933e2f0 100644 --- a/app/src/no_ads/java/com/mux/stats/sdk/muxstats/theoplayer/demo/MainActivity.java +++ b/app/src/no_ads/java/com/mux/stats/sdk/muxstats/theoplayer/demo/MainActivity.java @@ -17,6 +17,7 @@ import com.theoplayer.android.api.event.player.PlayerEventTypes; import com.theoplayer.android.api.player.Player; import com.theoplayer.android.api.source.SourceDescription; +import com.theoplayer.android.api.source.SourceType; import com.theoplayer.android.api.source.TypedSource; public class MainActivity extends AppCompatActivity { @@ -85,7 +86,10 @@ private void configureTHEOplayer() { theoPlayerView.getSettings().setFullScreenOrientationCoupled(true); // Creating a TypedSource builder that defines the location of a single stream source. - TypedSource.Builder typedSource = new TypedSource.Builder(getString(R.string.defaultSourceUrl)); +// TypedSource.Builder typedSource = new TypedSource.Builder(getString(R.string.defaultSourceUrl)); + TypedSource.Builder typedSource = new TypedSource.Builder("http://192.168.1.121:8000/playlist.mpd"); + + typedSource.type(SourceType.DASH); // Creating a SourceDescription builder that contains the settings to be applied as a new // THEOplayer source. @@ -95,6 +99,7 @@ private void configureTHEOplayer() { // Configuring THEOplayer with defined SourceDescription object. theoPlayer.setSource(sourceDescription.build()); + theoPlayer.setAutoplay(true); theoPlayer.addEventListener(PlayerEventTypes.PLAYING, event -> txtPlayStatus.setText("Playing") diff --git a/automatedtests/build.gradle b/automatedtests/build.gradle index c9a5bfb..8f58bc8 100644 --- a/automatedtests/build.gradle +++ b/automatedtests/build.gradle @@ -16,7 +16,7 @@ android { testInstrumentationRunnerArguments clearPackageData: "true" buildConfigField("boolean", "SHOULD_REPORT_INSTRUMENTATION_TEST_EVENTS_TO_SERVER", "true") - buildConfigField("String", "INSTRUMENTATION_TEST_ENVIRONMENT_KEY", "\"YOUR_ENVIRONMENT_KEY_HERE\"") + buildConfigField("String", "INSTRUMENTATION_TEST_ENVIRONMENT_KEY", "\"YOUR KEY HERE\"") var theoLicense = System.getenv("THEOPLAYER_LICENSE") == null ? "NOT_CONFIGURED" : System.getenv("THEOPLAYER_LICENSE") manifestPlaceholders.theoLicense = theoLicense } @@ -50,20 +50,6 @@ android { flavorDimensions "api" productFlavors { - minapi16 { - dimension "api" - } - minapi21 { - dimension "api" - minSdkVersion 21 - } - minapi16ads { - dimension "api" - } - minapi21ads { - dimension "api" - minSdkVersion 21 - } v5 { dimension 'api' minSdkVersion 21 @@ -103,12 +89,6 @@ dependencies { androidTestImplementation "androidx.test.ext:junit:1.1.5" implementation project(":muxstatssdktheoplayer") - - minapi16Implementation files("../common_libs/theoplayer-android-dist-56d3a9e5-4252-4bca-b650-180c8f16ce52-2.80.0-minapi16-release.aar") - minapi21Implementation files("../common_libs/theoplayer-android-dist-56d3a9e5-4252-4bca-b650-180c8f16ce52-2.80.0-minapi21-release.aar") - minapi16adsImplementation files("../common_libs/theoplayer-android-dist-56d3a9e5-4252-4bca-b650-180c8f16ce52-2.80.0-minapi16-release.aar") - minapi21adsImplementation files("../common_libs/theoplayer-android-dist-56d3a9e5-4252-4bca-b650-180c8f16ce52-2.80.0-minapi21-release.aar") - implementation "com.google.android.gms:play-services-auth:20.5.0" implementation "com.google.android.gms:play-services-ads-identifier:18.0.1" } diff --git a/automatedtests/src/androidTest/java/com/mux/stats/sdk/muxstats/automatedtests/RenditionChangeTests.java b/automatedtests/src/androidTest/java/com/mux/stats/sdk/muxstats/automatedtests/RenditionChangeTests.java index d727f65..fee5e1e 100644 --- a/automatedtests/src/androidTest/java/com/mux/stats/sdk/muxstats/automatedtests/RenditionChangeTests.java +++ b/automatedtests/src/androidTest/java/com/mux/stats/sdk/muxstats/automatedtests/RenditionChangeTests.java @@ -26,20 +26,26 @@ public class RenditionChangeTests extends TestBase { @Before public void init(){ -// urlToPlay = "http://localhost:5000/hls/google_glass/playlist.m3u8"; - urlToPlay = "http://localhost:5000/dash/google_glass/playlist.mpd"; + urlToPlay = "http://localhost:5000/hls/google_glass/playlist.m3u8"; +// urlToPlay = "http://localhost:5000/dash/google_glass/playlist.mpd"; +// urlToPlay = "https://cdn.theoplayer.com/video/dash/big_buck_bunny/BigBuckBunny_10s_simple_2014_05_09.mpd"; // These video have larger bitrate, make sure we do not cause any // rebuffering due to low bandwith bandwidthLimitInBitsPerSecond = 12000000; -// sourceType = SourceType.HLS; - sourceType = SourceType.DASH; + sourceType = SourceType.HLS; +// sourceType = SourceType.DASH; super.init(); } @Test public void testRenditionChange() { try { + if (playWhenReady) { + testActivity.runOnUiThread(() -> { + pView.getPlayer().play(); + }); + } if(!testActivity.waitForPlaybackToStart(waitForPlaybackToStartInMS)) { fail("Playback did not start in " + waitForPlaybackToStartInMS + " milliseconds !!!"); } diff --git a/automatedtests/src/androidTest/java/com/mux/stats/sdk/muxstats/automatedtests/TestBase.java b/automatedtests/src/androidTest/java/com/mux/stats/sdk/muxstats/automatedtests/TestBase.java index a829410..1b22c2f 100644 --- a/automatedtests/src/androidTest/java/com/mux/stats/sdk/muxstats/automatedtests/TestBase.java +++ b/automatedtests/src/androidTest/java/com/mux/stats/sdk/muxstats/automatedtests/TestBase.java @@ -86,7 +86,7 @@ public abstract class TestBase { // the regular amount of bytes to send. // This will stop server completly, this will allow us to easier calculate the rebuffer period protected int networkJamFactor = 5; - protected int waitForPlaybackToStartInMS = 30000; + protected int waitForPlaybackToStartInMS = 300000; protected long playbackStartPosition = 0; protected boolean playWhenReady = true; diff --git a/automatedtests/src/androidTest/java/com/mux/stats/sdk/muxstats/automatedtests/ui/SimplePlayerTestActivity.java b/automatedtests/src/androidTest/java/com/mux/stats/sdk/muxstats/automatedtests/ui/SimplePlayerTestActivity.java index d469826..3785a8e 100644 --- a/automatedtests/src/androidTest/java/com/mux/stats/sdk/muxstats/automatedtests/ui/SimplePlayerTestActivity.java +++ b/automatedtests/src/androidTest/java/com/mux/stats/sdk/muxstats/automatedtests/ui/SimplePlayerTestActivity.java @@ -129,6 +129,7 @@ public void startPlayback() { player.setSource(testMediaSource); player.setCurrentTime(playbackStartPosition); } + // Version 5.9.1 do not work very well with dash and HLS, only MP4 player.setAutoplay(playWhenReady); } diff --git a/muxstatssdktheoplayer/build.gradle b/muxstatssdktheoplayer/build.gradle index 8d70bf1..a5e7df6 100644 --- a/muxstatssdktheoplayer/build.gradle +++ b/muxstatssdktheoplayer/build.gradle @@ -32,20 +32,6 @@ android { flavorDimensions 'api' productFlavors { - minapi16 { - dimension 'api' - } - minapi21 { - dimension 'api' - minSdkVersion 21 - } - minapi16ads { - dimension 'api' - } - minapi21ads { - dimension 'api' - minSdkVersion 21 - } v5 { dimension 'api' minSdkVersion 21 @@ -81,17 +67,8 @@ muxDistribution { dependencies { implementation 'com.android.support:multidex:1.0.3' - - // Legacy versions use `compileOnly` to avoid binary incompatibility issues. - //noinspection GradleDependency - minapi16adsCompileOnly 'com.theoplayer.theoplayer-sdk-android:basic-minapi16:2.92.0' - //noinspection GradleDependency - minapi16CompileOnly 'com.theoplayer.theoplayer-sdk-android:basic-minapi16:2.92.0' - minapi21CompileOnly 'com.theoplayer.theoplayer-sdk-android:basic-minapi21:2.92.0' - minapi21adsCompileOnly 'com.theoplayer.theoplayer-sdk-android:basic-minapi21:2.92.0' - //noinspection GradleDynamicVersion // THEO claims there will be no breaking changes. - v5Api 'com.theoplayer.theoplayer-sdk-android:core:+' + v5Api 'com.theoplayer.theoplayer-sdk-android:core:5.9.1' //noinspection GradleDependency,GradleDynamicVersion // Old kotlin asked for by name in docs v5Api 'org.jetbrains.kotlin:kotlin-stdlib:1.6.+'