Skip to content

Commit

Permalink
Update theoplayer from v5->v7 + update dependencies + fix unit test (#30
Browse files Browse the repository at this point in the history
)

* Update theoplayer to v7, gradle update and other dependencies

* Fixing automated tests failing

* Update flavor from v5 -> v7

---------

Co-authored-by: Roel Wuytens <[email protected]>
  • Loading branch information
roelwuytens and roelwuytens-androme authored Jun 11, 2024
1 parent 72a33d0 commit 2aca218
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/saucelabs-tests-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
strategy:
max-parallel: 2
matrix:
player_version: [ 'v5' ]
player_version: [ 'v7' ]

env:
app_artifact: automatedtests\/buildout\/outputs\/apk\/${{ matrix.player_version }}\/debug\/automatedtests-${{ matrix.player_version }}-debug.apk
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/saucelabs-tests-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ jobs:
strategy:
max-parallel: 1
matrix:
# only run v5 for now, the v2 versions are very old
player_version: [ 'v5' ]
# only run v7 for now, the v2 versions are very old
player_version: [ 'v7' ]

env:
app_artifact: automatedtests\/buildout\/outputs\/apk\/${{ matrix.player_version }}\/debug\/automatedtests-${{ matrix.player_version }}-debug.apk
Expand Down
16 changes: 8 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ android {
}
}
sourceSets {
v5 {
v7 {
java.srcDirs = ["./src/no_ads/java"]
res.srcDirs = ["./src/no_ads/res"]
assets.srcDirs = ["./src/no_ads/assets"]
Expand All @@ -41,7 +41,7 @@ android {
flavorDimensions "api"

productFlavors {
v5 {
v7 {
dimension 'api'
minSdkVersion 21
}
Expand All @@ -62,15 +62,15 @@ android {
dependencies {
implementation "androidx.multidex:multidex:2.0.1"
implementation "com.android.support:multidex:1.0.3"
implementation "com.google.android.material:material:1.8.0"
api "org.checkerframework:checker-qual:3.32.0"
implementation "com.google.android.material:material:1.12.0"
api "org.checkerframework:checker-qual:3.33.0"
implementation project(":muxstatssdktheoplayer")

// Test against a specific version for consistent tests
implementation "com.theoplayer.theoplayer-sdk-android:integration-ads-ima:5.9.1"
implementation 'com.theoplayer.theoplayer-sdk-android:core:5.9.1'
implementation "com.theoplayer.theoplayer-sdk-android:integration-ads-ima:${project.ext.theoplayerVersion}"
implementation "com.theoplayer.theoplayer-sdk-android:core:${project.ext.theoplayerVersion}"

implementation "com.google.code.gson:gson:2.9.1"
implementation "androidx.constraintlayout:constraintlayout:2.2.0-alpha09"
implementation "com.google.code.gson:gson:2.10.1"
implementation "androidx.constraintlayout:constraintlayout:2.2.0-alpha13"
implementation "androidx.appcompat:appcompat:1.6.1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.theoplayer.android.api.source.TypedSource;
import com.theoplayer.android.api.source.addescription.AdDescription;
import com.theoplayer.android.api.source.addescription.GoogleImaAdDescription;
import com.theoplayer.android.api.source.addescription.THEOplayerAdDescription;

public class MainActivity extends AppCompatActivity {

Expand Down Expand Up @@ -89,7 +88,7 @@ private void configureTHEOplayer() {
// Coupling the orientation of the device with the fullscreen state.
// The player will go fullscreen when the device is rotated to landscape
// and will also exit fullscreen when the device is rotated back to portrait.
theoPlayerView.getSettings().setFullScreenOrientationCoupled(true);
theoPlayerView.getFullScreenManager().setFullScreenOrientationCoupled(true);
theoPlayer.addIntegration(GoogleImaIntegrationFactory.createGoogleImaIntegration(theoPlayerView));

//Creating a TypedSource builder that defines the location of a single stream source.
Expand Down
18 changes: 9 additions & 9 deletions automatedtests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ android {
flavorDimensions "api"

productFlavors {
v5 {
v7 {
dimension 'api'
minSdkVersion 21
}
Expand All @@ -76,28 +76,28 @@ dependencies {
implementation "androidx.multidex:multidex:2.0.1"
implementation "com.android.support:multidex:1.0.3"
implementation "androidx.appcompat:appcompat:1.6.1"
implementation "com.google.android.material:material:1.8.0"
implementation "com.google.android.material:material:1.12.0"
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation "androidx.navigation:navigation-fragment:2.5.3"
implementation "androidx.navigation:navigation-ui:2.5.3"
implementation "com.google.code.gson:gson:2.9.1"
implementation "androidx.navigation:navigation-fragment:2.7.7"
implementation "androidx.navigation:navigation-ui:2.7.7"
implementation "com.google.code.gson:gson:2.10.1"
androidTestImplementation "androidx.test:runner:1.5.2"
androidTestUtil "androidx.test:orchestrator:1.4.2"

// Test against a specific version for consistent tests
implementation 'com.theoplayer.theoplayer-sdk-android:integration-ads-ima:5.9.1'
implementation 'com.theoplayer.theoplayer-sdk-android:core:5.9.1'
implementation "com.theoplayer.theoplayer-sdk-android:integration-ads-ima:${project.ext.theoplayerVersion}"
implementation "com.theoplayer.theoplayer-sdk-android:core:${project.ext.theoplayerVersion}"

androidTestImplementation "androidx.test:rules:1.5.0"
// Optional -- Hamcrest library
androidTestImplementation "org.hamcrest:hamcrest-library:1.3"
// Optional -- UI testing with Espresso
androidTestImplementation "androidx.test.espresso:espresso-core:3.5.1"
// Optional -- UI testing with UI Automator
androidTestImplementation "androidx.test.uiautomator:uiautomator:2.2.0"
androidTestImplementation "androidx.test.uiautomator:uiautomator:2.3.0"
androidTestImplementation "androidx.test.ext:junit:1.1.5"

implementation project(":muxstatssdktheoplayer")
implementation "com.google.android.gms:play-services-auth:20.5.0"
implementation "com.google.android.gms:play-services-auth:21.1.1"
implementation "com.google.android.gms:play-services-ads-identifier:18.0.1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public class AdsPlaybackTests extends TestBase {
static final int BUMPER_AD_PERIOD = 5000;
static final int CAN_SKIP_AD_AFTER = 5000;

// Take some extra time then 500ms because it is sometimes slower (e.g. 780ms) on emulator
static final int ALLOWED_DELAY_WINDOW = 1000;


@Before
public void init(){
Expand Down Expand Up @@ -74,7 +77,10 @@ public void testPreRollAndBumperAds() {
Thread.sleep(PAUSE_PERIOD_IN_MS);
// resume the ad playback
resumePlayer();
Thread.sleep(PREROLL_AD_PERIOD + BUMPER_AD_PERIOD * 2);
// Wait until ads are played
Thread.sleep(PREROLL_AD_PERIOD / 2 + BUMPER_AD_PERIOD + 1000);
// Play some main-content
Thread.sleep(20 * 1000);

// Check ad start event
int playIndex = networkRequest.getIndexForFirstEvent(PlayEvent.TYPE);
Expand All @@ -84,7 +90,6 @@ public void testPreRollAndBumperAds() {
int adPlayingIndex = networkRequest.getIndexForFirstEvent(AdPlayingEvent.TYPE);

List<String> names = networkRequest.getReceivedEventNames();

if (playIndex == -1 || pauseIndex == -1
|| adBreakstartIndex == -1 || adPlayIndex == -1 || adPlayingIndex == -1) {
fail("Missing basic start events ! playIndex: " + playIndex +
Expand Down Expand Up @@ -120,13 +125,13 @@ public void testPreRollAndBumperAds() {
// fail("First ad pause period do not match expected pause period, reported pause period: " +
// firstAdPausePeriod + ", expected ad pause period: " + PAUSE_PERIOD_IN_MS);
// }

long expectedFirstAdPlayPeriod = PREROLL_AD_PERIOD;
// We also did pause so also add the pause period
long expectedFirstAdPlayPeriod = PREROLL_AD_PERIOD + PAUSE_PERIOD_IN_MS;
// Check rest of the first ad playback
int adEndedIndex = networkRequest.getIndexForNextEvent(adPlayingIndex, AdEndedEvent.TYPE);
long firstAdPlayPeriod = networkRequest.getCreationTimeForEvent(adEndedIndex) -
networkRequest.getCreationTimeForEvent(adPlayingIndex);
if (Math.abs(firstAdPlayPeriod - expectedFirstAdPlayPeriod) > 500) {
if (Math.abs(firstAdPlayPeriod - expectedFirstAdPlayPeriod) > ALLOWED_DELAY_WINDOW) {
fail("First ad play period do not match expected play period, reported: " +
firstAdPlayPeriod + ", expected ad play period: " + expectedFirstAdPlayPeriod);
}
Expand All @@ -136,7 +141,7 @@ public void testPreRollAndBumperAds() {
adEndedIndex = networkRequest.getIndexForNextEvent(adPlayingIndex, AdEndedEvent.TYPE);
long bumperAdPlayPeriod = networkRequest.getCreationTimeForEvent(adEndedIndex) -
networkRequest.getCreationTimeForEvent(adPlayingIndex);
if (Math.abs(bumperAdPlayPeriod - BUMPER_AD_PERIOD) > 500) {
if (Math.abs(bumperAdPlayPeriod - BUMPER_AD_PERIOD) > ALLOWED_DELAY_WINDOW) {
fail("Bumper ad period do not match expected bumper period, reported: " +
bumperAdPlayPeriod + ", expected ad play period: " + BUMPER_AD_PERIOD);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,9 @@ public void testVodPlayback() {
double seekToInFuture = currentPlaybackPosition + ((videoDuration - currentPlaybackPosition) / 2);
TimeRanges onBuffer = pView.getPlayer().getBuffered();
TimeRanges seekable = pView.getPlayer().getSeekable();
pView.getPlayer().setCurrentTime( seekToInFuture, () -> {
Log.w(TAG, "Seek in the future completed");
seekCompleted.set(true);
} );
pView.getPlayer().setCurrentTime(seekToInFuture);
Log.w(TAG, "Seek in the future completed");
seekCompleted.set(true);
});

// Play another x seconds, stage 7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import com.theoplayer.android.api.source.TypedSource;
import com.theoplayer.android.api.source.addescription.AdDescription;
import com.theoplayer.android.api.source.addescription.GoogleImaAdDescription;
import com.theoplayer.android.api.source.addescription.THEOplayerAdDescription;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ buildscript {
classpath 'com.novoda:bintray-release:0.9.1'
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4+"
classpath 'com.mux.gradle.android:mux-android-distribution:1.0.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.24"
}
}

Expand All @@ -36,12 +36,12 @@ allprojects {

project.ext {
minSdkVersion=16
compileSdkVersion=33
targetSdkVersion=33
compileSdkVersion=34
targetSdkVersion=34
releaseWebsite = 'https://github.com/muxinc/mux-stats-sdk-theoplayer-android'

theoplayerVersion = "2.92.0"
muxCoreVersion = "7.8.0"
theoplayerVersion = "7.2.0"
muxCoreVersion = "8.0.0"
}
}

Expand Down
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Jan 06 16:07:41 PST 2022
#Wed May 08 11:01:50 CEST 2024
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7 changes: 3 additions & 4 deletions muxstatssdktheoplayer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ android {
flavorDimensions 'api'

productFlavors {
v5 {
v7 {
dimension 'api'
minSdkVersion 21
}
Expand Down Expand Up @@ -68,10 +68,9 @@ muxDistribution {
dependencies {
implementation 'com.android.support:multidex:1.0.3'
//noinspection GradleDynamicVersion // THEO claims there will be no breaking changes.
v5Api "com.theoplayer.theoplayer-sdk-android:core:5.9.1"
v5Api "com.theoplayer.theoplayer-sdk-android:integration-ads-ima:5.9.1"
v7Api "com.theoplayer.theoplayer-sdk-android:core:${project.ext.theoplayerVersion}"
v7Api "com.theoplayer.theoplayer-sdk-android:integration-ads-ima:${project.ext.theoplayerVersion}"
//noinspection GradleDependency,GradleDynamicVersion // Old kotlin asked for by name in docs
v5Api 'org.jetbrains.kotlin:kotlin-stdlib:1.6.+'

// compileOnly 'com.google.ads.interactivemedia.v3:interactivemedia:3.31.0'
// compileOnly 'com.google.android.gms:play-services-ads-identifier:18.0.1'
Expand Down

0 comments on commit 2aca218

Please sign in to comment.