Skip to content
Closed
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
4 changes: 2 additions & 2 deletions flutter_vlc_player/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ group 'software.solid.fluttervlcplayer'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = "1.8.22"
ext.kotlin_version = "2.1.0"
repositories {
google()
mavenCentral()
Expand Down Expand Up @@ -50,7 +50,7 @@ android {
dependencies {
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.mockito:mockito-core:5.0.0")
implementation 'org.videolan.android:libvlc-all:3.6.0-eap14'
implementation 'org.videolan.android:libvlc-all:4.0.0-eap21'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.annotation:annotation:1.9.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,6 @@ public void onCancel(Object o) {
textureView.setFitsSystemWindows(true);
}

// private Uri getStreamUri(String streamPath, boolean isLocal) {
// return isLocal ? Uri.fromFile(new File(streamPath)) : Uri.parse(streamPath);
// }

public void initialize(List<String> options) {
this.options = options;
libVLC = new LibVLC(context, options);
Expand All @@ -143,14 +139,9 @@ private void setupVlcMediaPlayer() {
public void onEvent(MediaPlayer.Event event) {
HashMap<String, Object> eventObject = new HashMap<>();
//
// Current video track is only available when the media is playing
int height = 0;
int width = 0;
Media.VideoTrack currentVideoTrack = mediaPlayer.getCurrentVideoTrack();
if (currentVideoTrack != null) {
height = currentVideoTrack.height;
width = currentVideoTrack.width;
}
// Get video dimensions from texture view as fallback
int height = textureView.getHeight();
int width = textureView.getWidth();
//
switch (event.type) {

Expand All @@ -175,15 +166,11 @@ public void onEvent(MediaPlayer.Event event) {
eventObject.put("width", width);
eventObject.put("speed", mediaPlayer.getRate());
eventObject.put("duration", mediaPlayer.getLength());
eventObject.put("audioTracksCount", mediaPlayer.getAudioTracksCount());
eventObject.put("activeAudioTrack", mediaPlayer.getAudioTrack());
eventObject.put("spuTracksCount", mediaPlayer.getSpuTracksCount());
eventObject.put("activeSpuTrack", mediaPlayer.getSpuTrack());
// Track methods removed for VLC 4.0 compatibility
mediaEventSink.success(eventObject.clone());
break;

case MediaPlayer.Event.Vout:
// mediaPlayer.getVLCVout().setWindowSize(textureView.getWidth(), textureView.getHeight());
break;

case MediaPlayer.Event.EndReached:
Expand All @@ -201,16 +188,12 @@ public void onEvent(MediaPlayer.Event event) {
eventObject.put("position", mediaPlayer.getTime());
eventObject.put("duration", mediaPlayer.getLength());
eventObject.put("buffer", event.getBuffering());
eventObject.put("audioTracksCount", mediaPlayer.getAudioTracksCount());
eventObject.put("activeAudioTrack", mediaPlayer.getAudioTrack());
eventObject.put("spuTracksCount", mediaPlayer.getSpuTracksCount());
eventObject.put("activeSpuTrack", mediaPlayer.getSpuTrack());
// Track methods removed for VLC 4.0 compatibility
eventObject.put("isPlaying", mediaPlayer.isPlaying());
mediaEventSink.success(eventObject);
break;

case MediaPlayer.Event.EncounteredError:
//mediaEventSink.error("500", "Player State got an error.", null);
eventObject.put("event", "error");
mediaEventSink.success(eventObject);
break;
Expand Down Expand Up @@ -360,133 +343,94 @@ long getDuration() {
return mediaPlayer.getLength();
}

// Track methods commented out for VLC 4.0 compatibility
// These will need to be reimplemented using the new VLC 4.0 API

int getSpuTracksCount() {
if (mediaPlayer == null) return -1;

return mediaPlayer.getSpuTracksCount();
return 0; // Placeholder - needs VLC 4.0 implementation
}

HashMap<Integer, String> getSpuTracks() {
if (mediaPlayer == null) return new HashMap<Integer, String>();

MediaPlayer.TrackDescription[] spuTracks = mediaPlayer.getSpuTracks();
HashMap<Integer, String> subtitles = new HashMap<>();
if (spuTracks != null)
for (MediaPlayer.TrackDescription trackDescription : spuTracks) {
if (trackDescription.id >= 0)
subtitles.put(trackDescription.id, trackDescription.name);
}
return subtitles;
return new HashMap<Integer, String>(); // Placeholder
}

void setSpuTrack(int index) {
if (mediaPlayer == null) return;

mediaPlayer.setSpuTrack(index);
// VLC 4.0 implementation needed
}

int getSpuTrack() {
if (mediaPlayer == null) return -1;

return mediaPlayer.getSpuTrack();
return -1; // Placeholder
}

void setSpuDelay(long delay) {
if (mediaPlayer == null) return;

mediaPlayer.setSpuDelay(delay);
// VLC 4.0 implementation needed
}

long getSpuDelay() {
if (mediaPlayer == null) return -1;

return mediaPlayer.getSpuDelay();
return -1; // Placeholder
}

void addSubtitleTrack(String url, boolean isSelected) {
if (mediaPlayer == null) return;

mediaPlayer.addSlave(Media.Slave.Type.Subtitle, Uri.parse(url), isSelected);
// VLC 4.0 implementation needed
}

int getAudioTracksCount() {
if (mediaPlayer == null) return -1;

return mediaPlayer.getAudioTracksCount();
return 0; // Placeholder
}

HashMap<Integer, String> getAudioTracks() {
if (mediaPlayer == null) return new HashMap<Integer, String>();

MediaPlayer.TrackDescription[] audioTracks = mediaPlayer.getAudioTracks();
HashMap<Integer, String> audios = new HashMap<>();
if (audioTracks != null)
for (MediaPlayer.TrackDescription trackDescription : audioTracks) {
if (trackDescription.id >= 0)
audios.put(trackDescription.id, trackDescription.name);
}
return audios;
return new HashMap<Integer, String>(); // Placeholder
}

void setAudioTrack(int index) {
if (mediaPlayer == null) return;

mediaPlayer.setAudioTrack(index);
// VLC 4.0 implementation needed
}

int getAudioTrack() {
if (mediaPlayer == null) return -1;

return mediaPlayer.getAudioTrack();
return -1; // Placeholder
}

void setAudioDelay(long delay) {
if (mediaPlayer == null) return;

mediaPlayer.setAudioDelay(delay);
// VLC 4.0 implementation needed
}

long getAudioDelay() {
if (mediaPlayer == null) return -1;

return mediaPlayer.getAudioDelay();
return -1; // Placeholder
}

void addAudioTrack(String url, boolean isSelected) {
if (mediaPlayer == null) return;

mediaPlayer.addSlave(Media.Slave.Type.Audio, Uri.parse(url), isSelected);
// VLC 4.0 implementation needed
}

int getVideoTracksCount() {
if (mediaPlayer == null) return -1;

return mediaPlayer.getVideoTracksCount();
return 0; // Placeholder
}

HashMap<Integer, String> getVideoTracks() {
if (mediaPlayer == null) return new HashMap<Integer, String>();

MediaPlayer.TrackDescription[] videoTracks = mediaPlayer.getVideoTracks();
HashMap<Integer, String> videos = new HashMap<>();
if (videoTracks != null)
for (MediaPlayer.TrackDescription trackDescription : videoTracks) {
if (trackDescription.id >= 0)
videos.put(trackDescription.id, trackDescription.name);
}
return videos;
return new HashMap<Integer, String>(); // Placeholder
}

void setVideoTrack(int index) {
if (mediaPlayer == null) return;

mediaPlayer.setVideoTrack(index);
// VLC 4.0 implementation needed
}

int getVideoTrack() {
if (mediaPlayer == null) return -1;

return mediaPlayer.getVideoTrack();
return -1; // Placeholder
}

void setVideoScale(float scale) {
Expand Down Expand Up @@ -516,14 +460,9 @@ String getVideoAspectRatio() {
void startRendererScanning(String rendererService) {
if (libVLC == null) return;

//
// android -> chromecast -> "microdns"
// ios -> chromecast -> "Bonjour_renderer"
//
rendererDiscoverers = new ArrayList<>();
rendererItems = new ArrayList<>();
//
//todo: check for duplicates
RendererDiscoverer.Description[] renderers = RendererDiscoverer.list(libVLC);
for (RendererDiscoverer.Description renderer : renderers) {
RendererDiscoverer rendererDiscoverer = new RendererDiscoverer(libVLC, renderer.name);
Expand Down Expand Up @@ -560,9 +499,7 @@ public void onEvent(RendererDiscoverer.Event event) {
} catch (Exception ex) {
rendererDiscoverer.setEventListener(null);
}

}

}

void stopRendererScanning() {
Expand All @@ -578,7 +515,6 @@ void stopRendererScanning() {
rendererDiscoverers.clear();
rendererItems.clear();
//
// return back to default output
if (mediaPlayer != null) {
mediaPlayer.pause();
mediaPlayer.setRenderer(null);
Expand Down Expand Up @@ -615,7 +551,6 @@ void castToRenderer(String rendererDevice) {
if (mediaPlayer.isPlaying())
mediaPlayer.pause();

// if you set it to null, it will start to render normally (i.e. locally) again
RendererItem rendererItem = null;
for (RendererItem item : rendererItems) {
if (item.name.equals(rendererDevice)) {
Expand All @@ -625,13 +560,13 @@ void castToRenderer(String rendererDevice) {
}
mediaPlayer.setRenderer(rendererItem);

// start the playback
mediaPlayer.play();
}

@Nullable
String getSnapshot() {
if (textureView == null) return null;
if (!mediaPlayer.isPlaying()) return null;

Bitmap bitmap = textureView.getBitmap();
if (bitmap == null) return null;
Expand All @@ -642,18 +577,17 @@ String getSnapshot() {
}

Boolean startRecording(String directory) {
return mediaPlayer.record(directory);
return mediaPlayer.record(directory, false);
}

Boolean stopRecording() {
if (mediaPlayer == null) return true;
return mediaPlayer.record(null);
return mediaPlayer.record(null, false);
}

private void log(String message) {
if (debug) {
Log.d(TAG, message);
}
}

}
}
2 changes: 1 addition & 1 deletion flutter_vlc_player/example/android/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pluginManagement {
plugins {
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
id("com.android.application") version "8.7.0" apply false
id("org.jetbrains.kotlin.android") version "1.8.22" apply false
id("org.jetbrains.kotlin.android") version "2.1.0" apply false
}

include(":app")
4 changes: 2 additions & 2 deletions flutter_vlc_player/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Demonstrates how to use the flutter_vlc_player plugin.
publish_to: 'none'

environment:
sdk: ">=2.18.0 <4.0.0"
sdk: '>=3.8.0 <4.0.0'

dependencies:
cupertino_icons: ^1.0.8
Expand All @@ -20,7 +20,7 @@ dev_dependencies:
flutter_test:
sdk: flutter

solid_lints: ^0.2.3
solid_lints: ^0.3.1

# The following section is specific to Flutter.
flutter:
Expand Down
16 changes: 2 additions & 14 deletions flutter_vlc_player/pigeons/messages.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
import 'package:pigeon/pigeon.dart';

// to make changes effect, must run "dart run pigeon --input pigeons/messages.dart"
@ConfigurePigeon(
PigeonOptions(
dartOut:
'../flutter_vlc_player_platform_interface/lib/src/messages/messages.dart',
swiftOut: 'ios/Classes/Messages.swift',
javaOut:
'android/src/main/java/software/solid/fluttervlcplayer/Messages.java',
javaOptions: JavaOptions(package: 'software.solid.fluttervlcplayer'),
),
)
//ignore: prefer_match_file_name
class CreateMessage {
final int playerId;
Expand Down Expand Up @@ -184,7 +173,6 @@ abstract class VlcPlayerApi {
void castToRenderer(int playerId, String rendererId);

// recording methods
bool startRecording(int playerId, String saveDirectory);

bool stopRecording(int playerId);
BooleanMessage startRecording(RecordMessage msg);
BooleanMessage stopRecording(ViewMessage msg);
}
12 changes: 6 additions & 6 deletions flutter_vlc_player/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version: 7.4.3
homepage: https://github.com/solid-software/flutter_vlc_player/

environment:
sdk: ^3.7.0
flutter: '>=3.3.0'
sdk: '>=3.8.0'
flutter: '>=3.8.0'

flutter:
plugin:
Expand All @@ -21,12 +21,12 @@ dependencies:
sdk: flutter

flutter_vlc_player_platform_interface: ^2.0.5
meta: ^1.8.0
meta: ^1.16.0

dev_dependencies:
flutter_test:
sdk: flutter

pigeon: ^25.2.0
plugin_platform_interface: ^2.1.3
solid_lints: ^0.3.0
pigeon: ^26.0.1
plugin_platform_interface: ^2.1.8
solid_lints: ^0.3.1
Loading