Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/video_player/video_player_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 2.8.15

* Moves video event processing logic to Dart, and fixes an issue where buffer
range would not be updated for a paused video.
* Switches to Kotlin for Pigeon-generated code.
* Adopts type-safe event channels for internal communication.

## 2.8.14

* Restructures internal logic for player creation and tracking.
Expand Down
10 changes: 10 additions & 0 deletions packages/video_player/video_player_android/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ group 'io.flutter.plugins.videoplayer'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '2.2.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:8.12.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

Expand All @@ -20,6 +22,7 @@ rootProject.allprojects {
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
namespace = "io.flutter.plugins.videoplayer"
Expand All @@ -38,6 +41,13 @@ android {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

dependencies {
def exoplayer_version = "1.5.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import androidx.media3.exoplayer.ExoPlayer;

public abstract class ExoPlayerEventListener implements Player.Listener {
private boolean isBuffering = false;
private boolean isInitialized = false;
protected final ExoPlayer exoPlayer;
protected final VideoPlayerCallbacks events;
Expand Down Expand Up @@ -47,47 +46,34 @@ public ExoPlayerEventListener(
this.events = events;
}

private void setBuffering(boolean buffering) {
if (isBuffering == buffering) {
return;
}
isBuffering = buffering;
if (buffering) {
events.onBufferingStart();
} else {
events.onBufferingEnd();
}
}

protected abstract void sendInitialized();

@Override
public void onPlaybackStateChanged(final int playbackState) {
PlatformPlaybackState platformState = PlatformPlaybackState.UNKNOWN;
switch (playbackState) {
case Player.STATE_BUFFERING:
setBuffering(true);
events.onBufferingUpdate(exoPlayer.getBufferedPosition());
platformState = PlatformPlaybackState.BUFFERING;
break;
case Player.STATE_READY:
platformState = PlatformPlaybackState.READY;
if (!isInitialized) {
isInitialized = true;
sendInitialized();
}
break;
case Player.STATE_ENDED:
events.onCompleted();
platformState = PlatformPlaybackState.ENDED;
break;
case Player.STATE_IDLE:
platformState = PlatformPlaybackState.IDLE;
break;
}
if (playbackState != Player.STATE_BUFFERING) {
setBuffering(false);
}
events.onPlaybackStateChanged(platformState);
}

@Override
public void onPlayerError(@NonNull final PlaybackException error) {
setBuffering(false);
if (error.errorCode == PlaybackException.ERROR_CODE_BEHIND_LIVE_WINDOW) {
// See
// https://exoplayer.dev/live-streaming.html#behindlivewindowexception-and-error_code_behind_live_window
Expand Down
Loading