Skip to content

Commit

Permalink
Update Player version to 3.93.0
Browse files Browse the repository at this point in the history
  • Loading branch information
strangesource committed Nov 15, 2024
1 parent ef65e39 commit dbfd243
Show file tree
Hide file tree
Showing 16 changed files with 130 additions and 207 deletions.
1 change: 1 addition & 0 deletions Analytics/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".App"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.bitmovin.player.samples.analytics;

import android.app.Application;

import com.bitmovin.player.api.DebugConfig;

public class App extends Application {
@Override
public void onCreate() {
// DebugConfig.setLoggingEnabled(true); // Enable verbose debug logging in case of issues
super.onCreate();
}
}
1 change: 1 addition & 0 deletions AnalyticsKotlin/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".App"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.bitmovin.player.samples.analytics

import android.app.Application
import com.bitmovin.player.api.DebugConfig

class App : Application() {
override fun onCreate() {
// DebugConfig.isLoggingEnabled = true // Enable verbose debug logging in case of issues
super.onCreate()
}
}
1 change: 1 addition & 0 deletions BasicPlayback/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".App"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.bitmovin.player.samples.playback.basic;

import android.app.Application;

public class App extends Application {
@Override
public void onCreate() {
// DebugConfig.setLoggingEnabled(true); // Enable verbose debug logging in case of issues
super.onCreate();
}
}
1 change: 1 addition & 0 deletions BasicPlaybackKotlin/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".App"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.bitmovin.player.samples.playback.basic

import android.app.Application
import com.bitmovin.player.api.DebugConfig

class App : Application() {
override fun onCreate() {
// DebugConfig.isLoggingEnabled = true // Enable verbose debug logging in case of issues
super.onCreate()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.LinearLayout;

Expand All @@ -14,9 +13,6 @@
import com.bitmovin.player.api.Player;
import com.bitmovin.player.api.PlayerBuilder;
import com.bitmovin.player.api.PlayerConfig;
import com.bitmovin.player.api.event.EventListener;
import com.bitmovin.player.api.event.PlayerEvent;
import com.bitmovin.player.api.event.SourceEvent;
import com.bitmovin.player.api.source.SourceConfig;
import com.bitmovin.player.api.source.SourceType;
import com.bitmovin.player.api.ui.PlayerViewConfig;
Expand All @@ -25,12 +21,9 @@
import com.bitmovin.player.samples.tv.playback.basic.R;

public class MainActivity extends AppCompatActivity {
private static final String TAG = MainActivity.class.getSimpleName();
private static final int SEEKING_OFFSET = 10;

private PlayerView playerView;
private Player player;
private Double pendingSeekTarget;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -50,19 +43,20 @@ private void initializePlayer() {
.configureAnalytics(new AnalyticsConfig(key))
.build();

// Here a custom bitmovinplayer-ui.js is loaded which utilizes the cast-UI as this matches our needs here perfectly.
// I.e. UI controls get shown / hidden whenever the Player API is called. This is needed due to the fact that on Android TV no touch events are received
PlayerViewConfig viewConfig = new PlayerViewConfig(
new UiConfig.WebUi(
"file:///android_asset/bitmovinplayer-ui.css",
null,
"file:///android_asset/bitmovinplayer-ui.js",
true,
false,
null
null,
UiConfig.WebUi.Variant.TvUi.INSTANCE,
true
),
false,
ScalingMode.Fit
ScalingMode.Fit,
false
);

playerView = new PlayerView(this, player, viewConfig);
Expand Down Expand Up @@ -94,40 +88,6 @@ private PlayerConfig createPlayerConfig() {
return playerConfig;
}

@Override
protected void onResume() {
super.onResume();

playerView.onResume();
addEventListener();
player.play();
}

@Override
protected void onStart() {
super.onStart();
playerView.onStart();
}

@Override
protected void onPause() {
removeEventListener();
playerView.onPause();
super.onPause();
}

@Override
protected void onStop() {
playerView.onStop();
super.onStop();
}

@Override
protected void onDestroy() {
playerView.onDestroy();
super.onDestroy();
}

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
// This method is called on key down and key up, so avoid being called twice
Expand All @@ -142,35 +102,21 @@ public boolean dispatchKeyEvent(KeyEvent event) {
}

private boolean handleUserInput(int keycode) {
Log.d(TAG, "Keycode " + keycode);
switch (keycode) {
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
case KeyEvent.KEYCODE_NUMPAD_ENTER:
case KeyEvent.KEYCODE_SPACE:
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
return switch (keycode) {
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE -> {
togglePlay();
return true;
case KeyEvent.KEYCODE_MEDIA_PLAY:
yield true;
}
case KeyEvent.KEYCODE_MEDIA_PLAY -> {
player.play();
return true;
case KeyEvent.KEYCODE_MEDIA_PAUSE:
yield true;
}
case KeyEvent.KEYCODE_MEDIA_PAUSE -> {
player.pause();
return true;
case KeyEvent.KEYCODE_MEDIA_STOP:
stopPlayback();
return true;
case KeyEvent.KEYCODE_DPAD_RIGHT:
case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
seekForward();
return true;
case KeyEvent.KEYCODE_DPAD_LEFT:
case KeyEvent.KEYCODE_MEDIA_REWIND:
seekBackward();
return true;
default:
return false;
}
yield true;
}
default -> false;
};
}

private void togglePlay() {
Expand All @@ -181,49 +127,34 @@ private void togglePlay() {
}
}

private void stopPlayback() {
player.pause();
player.seek(0);
}

private void seekForward() {
seekRelative(SEEKING_OFFSET);
@Override
protected void onResume() {
super.onResume();
playerView.onResume();
player.play();
}

private void seekBackward() {
seekRelative(-SEEKING_OFFSET);
@Override
protected void onStart() {
super.onStart();
playerView.onStart();
}

private void seekRelative(double seekAmount) {
double seekStart = pendingSeekTarget == null ? player.getCurrentTime() : pendingSeekTarget;
double seekTarget = seekStart + seekAmount;
pendingSeekTarget = seekTarget;
player.seek(seekTarget);
@Override
protected void onPause() {
playerView.onPause();
super.onPause();
}


private void addEventListener() {
if (player == null) return;

player.on(PlayerEvent.Error.class, onPlayerError);
player.on(SourceEvent.Error.class, onSourceError);
player.on(PlayerEvent.Seeked.class, onSeeked);
@Override
protected void onStop() {
playerView.onStop();
super.onStop();
}

private void removeEventListener() {
if (player == null) return;

player.off(onPlayerError);
player.off(onSourceError);
player.off(onSeeked);
@Override
protected void onDestroy() {
playerView.onDestroy();
super.onDestroy();
}

private final EventListener<PlayerEvent.Error> onPlayerError = errorEvent ->
Log.e(TAG, "A player error occurred (" + errorEvent.getCode() + "): " + errorEvent.getMessage());

private final EventListener<SourceEvent.Error> onSourceError = errorEvent ->
Log.e(TAG, "A source error occurred (" + errorEvent.getCode() + "): " + errorEvent.getMessage());

private final EventListener<PlayerEvent.Seeked> onSeeked = event -> pendingSeekTarget = null;

}
Loading

0 comments on commit dbfd243

Please sign in to comment.