Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
15a0d09
Add platform interface changes
FirentisTFW Jan 21, 2025
25520fc
Add platform view support for Android
FirentisTFW Jan 21, 2025
28d38c5
Rearrange native unit tests after merge
FirentisTFW Jan 21, 2025
0d3a753
Remove a todo in web implementation
FirentisTFW Jan 21, 2025
ea16d63
Set initial value of nextNonTexturePlayerId to Long.MAX_VALUE
FirentisTFW Jan 21, 2025
25425ca
Use player provider instead of modifiable list
FirentisTFW Jan 21, 2025
ce2aa51
Remove empty line
FirentisTFW Jan 21, 2025
8aeca10
Check player view states in Dart unit tests
FirentisTFW Jan 21, 2025
209f34f
Restore previous formatting for comments
FirentisTFW Jan 21, 2025
42cb659
Add missing licenses
FirentisTFW Jan 21, 2025
690ec54
Format files
FirentisTFW Jan 21, 2025
6db9e6d
Fix linting issues
FirentisTFW Jan 21, 2025
277bff7
Rename textureId to playerId in platform interace methods
FirentisTFW Jan 21, 2025
5aca5db
Rename textureId to playerId in Android Dart files
FirentisTFW Jan 21, 2025
751d529
Rename textureId to playerId in Android native code
FirentisTFW Jan 21, 2025
e6f856b
Add an ignore to UI test (it times out on Firebase Test Lab)
FirentisTFW Jan 21, 2025
b752b4c
Merge branch 'main' into feature/video-player-android-platform-view-s…
FirentisTFW Jan 28, 2025
8fc1fa0
Bump platform interface dependency to 6.3.0
FirentisTFW Jan 28, 2025
b745dcc
Remove resolved todo and fix dartdocs
FirentisTFW Jan 28, 2025
773cfc1
Add missing import
FirentisTFW Jan 28, 2025
89dfcea
Format test file
FirentisTFW Jan 28, 2025
f59463a
Add more context to class names for native views
FirentisTFW Jan 28, 2025
650cc21
Add missing docs for Android
FirentisTFW Jan 28, 2025
18463e7
Format file
FirentisTFW Jan 28, 2025
11647d0
Remove redundant async keyword
FirentisTFW Jan 29, 2025
8f9ccd8
Depend on platform interface 6.3.0
FirentisTFW Feb 10, 2025
0c2e19b
Add more details to javadocs for players
FirentisTFW Feb 10, 2025
17d5c6c
Rename method for clarity
FirentisTFW Feb 10, 2025
10640da
Remove "///" from a javadoc
FirentisTFW Feb 11, 2025
7917c0c
Add unit tests for NativeVideoView and NativeVideoViewFactory
FirentisTFW Feb 19, 2025
06b20a1
Add unit tests for VideoPlayerPlugin.create method
FirentisTFW Feb 19, 2025
1e51f8c
Add empty line to separate concepts
FirentisTFW Feb 19, 2025
e2a5afa
Clean up newly added tests
FirentisTFW Feb 19, 2025
2692564
Sort imports
FirentisTFW Feb 19, 2025
f5258df
Add missing licenses
FirentisTFW Feb 19, 2025
1bbe2c2
Split ExoPlayerEventListener into two classes, for platform view and …
FirentisTFW Feb 24, 2025
f43e9ba
Make class final
FirentisTFW Feb 24, 2025
22c9241
Use "PlatformView" instead of "NativeView" everywhere
FirentisTFW Feb 24, 2025
df3959d
Rename TextureBased to Texture, move texture player to a separate pac…
FirentisTFW Feb 24, 2025
4575c4c
Make VideoPlayer abstract
FirentisTFW Feb 24, 2025
eae1eb5
Clean up analysis
FirentisTFW Feb 24, 2025
c39b14c
Rename nextNonTexturePlayerId to nextPlatformViewPlayerId
FirentisTFW Feb 24, 2025
8d3279d
Split tests for exo player event listeners
FirentisTFW Feb 24, 2025
2862323
Update implementation comment
FirentisTFW Feb 24, 2025
314bf82
Use widget instead of a method
FirentisTFW Feb 24, 2025
feca35d
Move VideoPlayerProvider to PlatformVideoViewFactory
FirentisTFW Feb 24, 2025
7956b19
Comment on swapping width and height
FirentisTFW Feb 25, 2025
70ed428
Remove redundant abstract class method
FirentisTFW Feb 25, 2025
ce63f14
Handle SurfaceView on Android 9 correctly, document workarounds
FirentisTFW Feb 25, 2025
81a71a3
Test output, not internal state
FirentisTFW Feb 25, 2025
41891d2
Remove overriden == operator as it's not needed anymore
FirentisTFW Feb 25, 2025
6bf34e7
Clean up code
FirentisTFW Feb 25, 2025
dc08e2d
Format code
FirentisTFW Feb 25, 2025
0681400
Use custom test class in VideoPlayerTest
FirentisTFW Feb 25, 2025
b0f282d
Add missing licenses
FirentisTFW Feb 25, 2025
6c17ebc
Add a todo to decouple identifiers in the future
FirentisTFW Feb 26, 2025
9895676
Format file
FirentisTFW Feb 26, 2025
da1b78d
Resolve lint issues
FirentisTFW Feb 26, 2025
ae4bfae
Inline method
FirentisTFW Feb 26, 2025
371c462
Format file
FirentisTFW Feb 26, 2025
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
Prev Previous commit
Next Next commit
Resolve lint issues
  • Loading branch information
FirentisTFW committed Feb 26, 2025
commit da1b78d77cbd896e096925410e63f4f4dfc5a730
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public int getDegrees() {
}

public ExoPlayerEventListener(
ExoPlayer exoPlayer, VideoPlayerCallbacks events, boolean initialized) {
@NonNull ExoPlayer exoPlayer, @NonNull VideoPlayerCallbacks events, boolean initialized) {
this.exoPlayer = exoPlayer;
this.events = events;
this.isInitialized = initialized;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package io.flutter.plugins.videoplayer;

import androidx.annotation.NonNull;
import androidx.media3.common.PlaybackParameters;
import androidx.media3.exoplayer.ExoPlayer;

Expand All @@ -24,7 +25,7 @@ public final class ExoPlayerState {
* @param exoPlayer the active player instance.
* @return an opaque object representing the state.
*/
public static ExoPlayerState save(ExoPlayer exoPlayer) {
@NonNull public static ExoPlayerState save(@NonNull ExoPlayer exoPlayer) {
return new ExoPlayerState(
/*position=*/ exoPlayer.getCurrentPosition(),
/*repeatMode=*/ exoPlayer.getRepeatMode(),
Expand Down Expand Up @@ -60,7 +61,7 @@ private ExoPlayerState(
*
* @param exoPlayer the new player instance to reflect the state back to.
*/
public void restore(ExoPlayer exoPlayer) {
public void restore(@NonNull ExoPlayer exoPlayer) {
exoPlayer.seekTo(position);
exoPlayer.setRepeatMode(repeatMode);
exoPlayer.setVolume(volume);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ public MediaItem getMediaItem() {
return builder.build();
}

@NonNull
@Override
public MediaSource.Factory getMediaSourceFactory(Context context) {
public MediaSource.Factory getMediaSourceFactory(@NonNull Context context) {
return getMediaSourceFactory(context, new DefaultHttpDataSource.Factory());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ public MediaItem getMediaItem() {
return new MediaItem.Builder().setUri(assetUrl).build();
}

@NonNull
@Override
public MediaSource.Factory getMediaSourceFactory(Context context) {
public MediaSource.Factory getMediaSourceFactory(@NonNull Context context) {
return new DefaultMediaSourceFactory(context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ protected VideoAsset(@Nullable String assetUrl) {
* @param context application context.
* @return configured factory, or {@code null} if not needed for this asset type.
*/
public abstract MediaSource.Factory getMediaSourceFactory(Context context);
@NonNull
public abstract MediaSource.Factory getMediaSourceFactory(@NonNull Context context);

/** Streaming formats that can be provided to the video player as a hint. */
enum StreamingFormat {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,23 @@ public interface ExoPlayerProvider {
*
* @return new instance.
*/
@NonNull
ExoPlayer get();
}

public VideoPlayer(
@NonNull ExoPlayerProvider exoPlayerProvider,
@NonNull VideoPlayerCallbacks events,
@NonNull MediaItem mediaItem,
@NonNull VideoPlayerOptions options) {
this.exoPlayerProvider = exoPlayerProvider;
@NonNull VideoPlayerOptions options,
@NonNull ExoPlayerProvider exoPlayerProvider) {
this.videoPlayerEvents = events;
this.mediaItem = mediaItem;
this.options = options;
this.exoPlayerProvider = exoPlayerProvider;
this.exoPlayer = createVideoPlayer();
}

@NonNull
protected ExoPlayer createVideoPlayer() {
ExoPlayer exoPlayer = exoPlayerProvider.get();
exoPlayer.setMediaItem(mediaItem);
Expand All @@ -59,7 +61,9 @@ protected ExoPlayer createVideoPlayer() {
return exoPlayer;
}

protected abstract ExoPlayerEventListener createExoPlayerEventListener(ExoPlayer exoPlayer);
@NonNull
protected abstract ExoPlayerEventListener createExoPlayerEventListener(
@NonNull ExoPlayer exoPlayer);

void sendBufferingUpdate() {
videoPlayerEvents.onBufferingUpdate(exoPlayer.getBufferedPosition());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package io.flutter.plugins.videoplayer.platformview;

import androidx.annotation.NonNull;
import androidx.annotation.OptIn;
import androidx.annotation.VisibleForTesting;
import androidx.media3.common.Format;
Expand All @@ -15,12 +16,13 @@

public final class PlatformViewExoPlayerEventListener extends ExoPlayerEventListener {
@VisibleForTesting
public PlatformViewExoPlayerEventListener(ExoPlayer exoPlayer, VideoPlayerCallbacks events) {
public PlatformViewExoPlayerEventListener(
@NonNull ExoPlayer exoPlayer, @NonNull VideoPlayerCallbacks events) {
this(exoPlayer, events, false);
}

public PlatformViewExoPlayerEventListener(
ExoPlayer exoPlayer, VideoPlayerCallbacks events, boolean initialized) {
@NonNull ExoPlayer exoPlayer, @NonNull VideoPlayerCallbacks events, boolean initialized) {
super(exoPlayer, events, initialized);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
public class PlatformViewVideoPlayer extends VideoPlayer {
@VisibleForTesting
public PlatformViewVideoPlayer(
@NonNull ExoPlayerProvider exoPlayerProvider,
@NonNull VideoPlayerCallbacks events,
@NonNull MediaItem mediaItem,
@NonNull VideoPlayerOptions options) {
super(exoPlayerProvider, events, mediaItem, options);
@NonNull VideoPlayerOptions options,
@NonNull ExoPlayerProvider exoPlayerProvider) {
super(events, mediaItem, options, exoPlayerProvider);
}

/**
Expand All @@ -45,19 +45,20 @@ public static PlatformViewVideoPlayer create(
@NonNull VideoAsset asset,
@NonNull VideoPlayerOptions options) {
return new PlatformViewVideoPlayer(
events,
asset.getMediaItem(),
options,
() -> {
ExoPlayer.Builder builder =
new ExoPlayer.Builder(context)
.setMediaSourceFactory(asset.getMediaSourceFactory(context));
return builder.build();
},
events,
asset.getMediaItem(),
options);
});
}

@NonNull
@Override
protected ExoPlayerEventListener createExoPlayerEventListener(ExoPlayer exoPlayer) {
protected ExoPlayerEventListener createExoPlayerEventListener(@NonNull ExoPlayer exoPlayer) {
// Platform view video player does not suspend and re-create the exoPlayer, hence initialized
// is always false.
return new PlatformViewExoPlayerEventListener(exoPlayer, videoPlayerEvents, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package io.flutter.plugins.videoplayer.texture;

import android.os.Build;
import androidx.annotation.NonNull;
import androidx.annotation.OptIn;
import androidx.annotation.VisibleForTesting;
import androidx.media3.common.Format;
Expand All @@ -16,12 +17,13 @@

public final class TextureExoPlayerEventListener extends ExoPlayerEventListener {
@VisibleForTesting
public TextureExoPlayerEventListener(ExoPlayer exoPlayer, VideoPlayerCallbacks events) {
public TextureExoPlayerEventListener(
@NonNull ExoPlayer exoPlayer, @NonNull VideoPlayerCallbacks events) {
this(exoPlayer, events, false);
}

public TextureExoPlayerEventListener(
ExoPlayer exoPlayer, VideoPlayerCallbacks events, boolean initialized) {
@NonNull ExoPlayer exoPlayer, @NonNull VideoPlayerCallbacks events, boolean initialized) {
super(exoPlayer, events, initialized);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,35 +49,36 @@ public static TextureVideoPlayer create(
@NonNull VideoAsset asset,
@NonNull VideoPlayerOptions options) {
return new TextureVideoPlayer(
events,
surfaceProducer,
asset.getMediaItem(),
options,
() -> {
ExoPlayer.Builder builder =
new ExoPlayer.Builder(context)
.setMediaSourceFactory(asset.getMediaSourceFactory(context));
return builder.build();
},
events,
surfaceProducer,
asset.getMediaItem(),
options);
});
}

@VisibleForTesting
public TextureVideoPlayer(
@NonNull ExoPlayerProvider exoPlayerProvider,
@NonNull VideoPlayerCallbacks events,
@NonNull TextureRegistry.SurfaceProducer surfaceProducer,
@NonNull MediaItem mediaItem,
@NonNull VideoPlayerOptions options) {
super(exoPlayerProvider, events, mediaItem, options);
@NonNull VideoPlayerOptions options,
@NonNull ExoPlayerProvider exoPlayerProvider) {
super(events, mediaItem, options, exoPlayerProvider);

this.surfaceProducer = surfaceProducer;
surfaceProducer.setCallback(this);

this.exoPlayer.setVideoSurface(surfaceProducer.getSurface());
}

@NonNull
@Override
protected ExoPlayerEventListener createExoPlayerEventListener(ExoPlayer exoPlayer) {
protected ExoPlayerEventListener createExoPlayerEventListener(@NonNull ExoPlayer exoPlayer) {
return new TextureExoPlayerEventListener(
exoPlayer, videoPlayerEvents, playerHasBeenSuspended());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ public MediaItem getMediaItem() {
return new MediaItem.Builder().setUri(assetUrl).build();
}

@NonNull
@Override
public MediaSource.Factory getMediaSourceFactory(Context context) {
public MediaSource.Factory getMediaSourceFactory(@NonNull Context context) {
return mediaSourceFactory;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private VideoPlayer createVideoPlayer() {

private TextureVideoPlayer createVideoPlayer(VideoPlayerOptions options) {
return new TextureVideoPlayer(
() -> mockExoPlayer, mockEvents, mockProducer, fakeVideoAsset.getMediaItem(), options);
mockEvents, mockProducer, fakeVideoAsset.getMediaItem(), options, () -> mockExoPlayer);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,16 @@ public final class VideoPlayerTest {
/** A test subclass of {@link VideoPlayer} that exposes the abstract class for testing. */
private final class TestVideoPlayer extends VideoPlayer {
private TestVideoPlayer(
@NonNull ExoPlayerProvider exoPlayerProvider,
@NonNull VideoPlayerCallbacks events,
@NonNull MediaItem mediaItem,
@NonNull VideoPlayerOptions options) {
super(exoPlayerProvider, events, mediaItem, options);
@NonNull VideoPlayerOptions options,
@NonNull ExoPlayerProvider exoPlayerProvider) {
super(events, mediaItem, options, exoPlayerProvider);
}

@NonNull
@Override
protected ExoPlayerEventListener createExoPlayerEventListener(ExoPlayer exoPlayer) {
protected ExoPlayerEventListener createExoPlayerEventListener(@NonNull ExoPlayer exoPlayer) {
// Use platform view implementation for testing.
return new PlatformViewExoPlayerEventListener(exoPlayer, mockEvents);
}
Expand All @@ -79,7 +80,7 @@ private VideoPlayer createVideoPlayer() {

private VideoPlayer createVideoPlayer(VideoPlayerOptions options) {
return new TestVideoPlayer(
() -> mockExoPlayer, mockEvents, fakeVideoAsset.getMediaItem(), options);
mockEvents, fakeVideoAsset.getMediaItem(), options, () -> mockExoPlayer);
}

@Test
Expand Down