From f2a242918d0e76e00a27fedcd11df17fa4829d8b Mon Sep 17 00:00:00 2001 From: mitch Date: Sat, 23 May 2020 22:37:52 -0400 Subject: [PATCH 01/13] Bugfix for https://github.com/solid-software/flutter_vlc_player/issues/52 Bugfix --- .../software/solid/fluttervlcplayer/FlutterVideoView.java | 4 ++-- example/android/build.gradle | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/software/solid/fluttervlcplayer/FlutterVideoView.java b/android/src/main/java/software/solid/fluttervlcplayer/FlutterVideoView.java index 77918b92..56e791a0 100755 --- a/android/src/main/java/software/solid/fluttervlcplayer/FlutterVideoView.java +++ b/android/src/main/java/software/solid/fluttervlcplayer/FlutterVideoView.java @@ -165,7 +165,7 @@ public void onMethodCall(MethodCall methodCall, @NonNull MethodChannel.Result re vout.attachViews(); String initStreamURL = methodCall.argument("url"); - Media media = new Media(libVLC, Uri.parse(Uri.decode(initStreamURL))); + Media media = new Media(libVLC, Uri.parse(initStreamURL)); mediaPlayer.setMedia(media); result.success(null); @@ -178,7 +178,7 @@ public void onMethodCall(MethodCall methodCall, @NonNull MethodChannel.Result re mediaPlayer.stop(); String newURL = methodCall.argument("url"); - Media newMedia = new Media(libVLC, Uri.parse(Uri.decode(newURL))); + Media newMedia = new Media(libVLC, Uri.parse(newURL)); mediaPlayer.setMedia(newMedia); result.success(null); diff --git a/example/android/build.gradle b/example/android/build.gradle index 4874c0a6..91c94778 100755 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -5,7 +5,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.6.1' + classpath 'com.android.tools.build:gradle:3.6.3' } } From c785f1828caab847096eeec4ecd88b406c18c23d Mon Sep 17 00:00:00 2001 From: mitch Date: Sat, 23 May 2020 22:38:55 -0400 Subject: [PATCH 02/13] spec bump --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 92ded1c0..9a28f6db 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_vlc_player description: A VLC-powered alternative to Flutter's video_player. Supports multiple players on one screen. -version: 3.0.0 +version: 3.0.1 homepage: https://github.com/solid-software/flutter_vlc_player environment: From c5629d9895293764f52ccd6551f9648efa887426 Mon Sep 17 00:00:00 2001 From: mitch Date: Sun, 24 May 2020 11:51:02 -0400 Subject: [PATCH 03/13] changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 659dd630..7d11ad3b 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.0.1 +* Fix a bug on Android with URL parsing. See (https://github.com/solid-software/flutter_vlc_player/issues/52), +credits to pharshdev (https://github.com/pharshdev) and Mitch Ross (https://github.com/mitchross) + ## 3.0.0 * Migrated to Swift, thanks to Mitch Ross (https://github.com/mitchross), Amadeu Cavalcante (https://github.com/amadeu01) and pharshdev (https://github.com/pharshdev). From 9aac8d954d0e2df19d17a92b0e879519f5a966ea Mon Sep 17 00:00:00 2001 From: mitch Date: Fri, 29 May 2020 12:13:09 -0400 Subject: [PATCH 04/13] bugfix, podspec update --- ios/flutter_vlc_player.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/flutter_vlc_player.podspec b/ios/flutter_vlc_player.podspec index 7f225b72..a742a642 100755 --- a/ios/flutter_vlc_player.podspec +++ b/ios/flutter_vlc_player.podspec @@ -4,7 +4,7 @@ # Pod::Spec.new do |s| s.name = 'flutter_vlc_player' - s.version = '3.0.0' + s.version = '3.0.1' s.summary = 'A new flutter plugin project.' s.description = <<-DESC A VLC-powered alternative to Flutter video_player. Supports multiple players on one screen. @@ -16,7 +16,7 @@ Pod::Spec.new do |s| s.source_files = 'Classes/**/*' s.dependency 'Flutter' s.platform = :ios, '9.0' - s.dependency 'MobileVLCKit', '~> 3.3.11' + s.dependency 'MobileVLCKit', '~> 3.3.12' s.static_framework = true # Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported. From c1ab9a4070e6c1990ec831c4deb10db7b2465120 Mon Sep 17 00:00:00 2001 From: mitch Date: Fri, 29 May 2020 12:53:22 -0400 Subject: [PATCH 05/13] Changelog update --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d11ad3b..eae06f7d 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.0.1 +* Updates MobileVLC to fix a bug on ios with HLS Streaming on VLCKit itself. See (https://code.videolan.org/videolan/VLCKit/-/issues/368), +credits to Mitch Ross (https://github.com/mitchross) + ## 3.0.1 * Fix a bug on Android with URL parsing. See (https://github.com/solid-software/flutter_vlc_player/issues/52), credits to pharshdev (https://github.com/pharshdev) and Mitch Ross (https://github.com/mitchross) From 6b07983e909b8127551ff2f928612b2ebd310b24 Mon Sep 17 00:00:00 2001 From: mitch Date: Fri, 29 May 2020 13:02:57 -0400 Subject: [PATCH 06/13] Updates version --- ios/flutter_vlc_player.podspec | 2 +- pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/flutter_vlc_player.podspec b/ios/flutter_vlc_player.podspec index a742a642..3d23dac3 100755 --- a/ios/flutter_vlc_player.podspec +++ b/ios/flutter_vlc_player.podspec @@ -4,7 +4,7 @@ # Pod::Spec.new do |s| s.name = 'flutter_vlc_player' - s.version = '3.0.1' + s.version = '3.0.2' s.summary = 'A new flutter plugin project.' s.description = <<-DESC A VLC-powered alternative to Flutter video_player. Supports multiple players on one screen. diff --git a/pubspec.yaml b/pubspec.yaml index 9a28f6db..8990e490 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_vlc_player description: A VLC-powered alternative to Flutter's video_player. Supports multiple players on one screen. -version: 3.0.1 +version: 3.0.2 homepage: https://github.com/solid-software/flutter_vlc_player environment: From ee14e4487944e0d925e6b0e84fa92e3809a4a80d Mon Sep 17 00:00:00 2001 From: Harsh Date: Tue, 23 Jun 2020 11:14:00 +0530 Subject: [PATCH 07/13] add vlc options from flutter --- .../fluttervlcplayer/FlutterVideoView.java | 19 ++++++++++--------- example/lib/main.dart | 7 +++++++ lib/flutter_vlc_player.dart | 12 +++++++++--- pubspec.yaml | 2 +- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/android/src/main/java/software/solid/fluttervlcplayer/FlutterVideoView.java b/android/src/main/java/software/solid/fluttervlcplayer/FlutterVideoView.java index 56e791a0..de9fb147 100755 --- a/android/src/main/java/software/solid/fluttervlcplayer/FlutterVideoView.java +++ b/android/src/main/java/software/solid/fluttervlcplayer/FlutterVideoView.java @@ -144,15 +144,16 @@ public void onMethodCall(MethodCall methodCall, @NonNull MethodChannel.Result re textureView = new TextureView(context); } - ArrayList options = new ArrayList<>(); - options.add("--no-drop-late-frames"); - options.add("--no-skip-frames"); - options.add("--rtsp-tcp"); - - if(DISABLE_LOG_OUTPUT) { - // Silence player log output. - options.add("--quiet"); - } + ArrayList options = methodCall.argument("options"); + // options.add("--no-drop-late-frames"); + // options.add("--no-skip-frames"); + // options.add("--rtsp-tcp"); + + // if(DISABLE_LOG_OUTPUT) { + // // Silence player log output. + // options.add("--quiet"); + // } + System.out.println("Adding VLC options: " + options); libVLC = new LibVLC(context, options); mediaPlayer = new MediaPlayer(libVLC); diff --git a/example/lib/main.dart b/example/lib/main.dart index 208f588c..963342da 100755 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -69,6 +69,13 @@ class MyAppScaffoldState extends State { url: "http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_60fps_normal.mp4", controller: _videoViewController, + // Play with vlc options + options: [ + '--quiet', + '--no-drop-late-frames', + '--no-skip-frames', + '--rtsp-tcp' + ], placeholder: Container( height: 250.0, child: Row( diff --git a/lib/flutter_vlc_player.dart b/lib/flutter_vlc_player.dart index 033efb3a..e7df2b89 100755 --- a/lib/flutter_vlc_player.dart +++ b/lib/flutter_vlc_player.dart @@ -23,6 +23,7 @@ class Size { class VlcPlayer extends StatefulWidget { final double aspectRatio; + final List options; final String url; final Widget placeholder; final VlcPlayerController controller; @@ -42,6 +43,10 @@ class VlcPlayer extends StatefulWidget { /// [VlcPlayerController.setStreamUrl] method so this can be changed at any time. @required this.url, + /// Adds options to vlc. For more [https://wiki.videolan.org/VLC_command-line_help] If nothing is provided, + /// vlc will run without any options set. + this.options, + /// Before the platform view has initialized, this placeholder will be rendered instead of the video player. /// This can simply be a [CircularProgressIndicator] (see the example.) this.placeholder, @@ -120,7 +125,7 @@ class _VlcPlayerState extends State // Once the controller has clients registered, we're good to register // with LibVLC on the platform side. if (_controller.hasClients) { - await _controller._initialize(widget.url); + await _controller._initialize(widget.options, widget.url); } } @@ -244,10 +249,11 @@ class VlcPlayerController { _eventHandlers.forEach((handler) => handler()); } - Future _initialize(String url) async { + Future _initialize(List options, String url) async { //if(initialized) throw new Exception("Player already initialized!"); - await _methodChannel.invokeMethod("initialize", {'url': url}); + await _methodChannel + .invokeMethod("initialize", {'url': url, 'options': options ?? []}); _position = 0; _eventChannel.receiveBroadcastStream().listen((event) { diff --git a/pubspec.yaml b/pubspec.yaml index 8990e490..9efee0d2 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_vlc_player description: A VLC-powered alternative to Flutter's video_player. Supports multiple players on one screen. -version: 3.0.2 +version: 3.0.3 homepage: https://github.com/solid-software/flutter_vlc_player environment: From cf26a549c8bf94bead8755b9744a641bf525f156 Mon Sep 17 00:00:00 2001 From: Harsh Date: Tue, 23 Jun 2020 13:42:49 +0530 Subject: [PATCH 08/13] add option for hw_acc --- .../fluttervlcplayer/FlutterVideoView.java | 76 +++++++++++++------ lib/flutter_vlc_player.dart | 37 ++++++++- 2 files changed, 84 insertions(+), 29 deletions(-) diff --git a/android/src/main/java/software/solid/fluttervlcplayer/FlutterVideoView.java b/android/src/main/java/software/solid/fluttervlcplayer/FlutterVideoView.java index de9fb147..32cfa6e2 100755 --- a/android/src/main/java/software/solid/fluttervlcplayer/FlutterVideoView.java +++ b/android/src/main/java/software/solid/fluttervlcplayer/FlutterVideoView.java @@ -9,10 +9,13 @@ import android.view.Surface; import android.view.TextureView; import android.view.View; + import androidx.annotation.NonNull; + import io.flutter.plugin.common.*; import io.flutter.plugin.platform.PlatformView; import io.flutter.view.TextureRegistry; + import org.videolan.libvlc.IVLCVout; import org.videolan.libvlc.LibVLC; import org.videolan.libvlc.Media; @@ -27,6 +30,10 @@ class FlutterVideoView implements PlatformView, MethodChannel.MethodCallHandler, // Silences player log output. private static final boolean DISABLE_LOG_OUTPUT = true; + private static final int HW_ACCELERATION_AUTOMATIC = -1; + private static final int HW_ACCELERATION_DISABLED = 0; + private static final int HW_ACCELERATION_DECODING = 1; + private static final int HW_ACCELERATION_FULL = 2; final PluginRegistry.Registrar registrar; private final MethodChannel methodChannel; @@ -52,34 +59,34 @@ public FlutterVideoView(Context context, PluginRegistry.Registrar _registrar, Bi eventChannel = new EventChannel(messenger, "flutter_video_plugin/getVideoEvents_" + id); eventChannel.setStreamHandler( - new EventChannel.StreamHandler() { - @Override - public void onListen(Object o, EventChannel.EventSink sink) { - eventSink.setDelegate(sink); - } + new EventChannel.StreamHandler() { + @Override + public void onListen(Object o, EventChannel.EventSink sink) { + eventSink.setDelegate(sink); + } - @Override - public void onCancel(Object o) { - eventSink.setDelegate(null); + @Override + public void onCancel(Object o) { + eventSink.setDelegate(null); + } } - } ); TextureRegistry.SurfaceTextureEntry textureEntry = registrar.textures().createSurfaceTexture(); textureView = new TextureView(context); textureView.setSurfaceTexture(textureEntry.surfaceTexture()); - textureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener(){ + textureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() { boolean wasPaused = false; @Override public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { - if(vout == null) return; + if (vout == null) return; vout.setVideoSurface(new Surface(textureView.getSurfaceTexture()), null); vout.attachViews(); textureView.forceLayout(); - if(wasPaused){ + if (wasPaused) { mediaPlayer.play(); wasPaused = false; } @@ -92,15 +99,15 @@ public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int h @Override public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) { - if(playerDisposed){ - if(mediaPlayer != null) { + if (playerDisposed) { + if (mediaPlayer != null) { mediaPlayer.stop(); mediaPlayer.release(); mediaPlayer = null; } return true; - }else{ - if(mediaPlayer != null && vout != null) { + } else { + if (mediaPlayer != null && vout != null) { mediaPlayer.pause(); wasPaused = true; vout.detachViews(); @@ -127,8 +134,8 @@ public View getView() { @Override public void dispose() { - if(mediaPlayer != null) mediaPlayer.stop(); - if(vout != null) vout.detachViews(); + if (mediaPlayer != null) mediaPlayer.stop(); + if (vout != null) vout.detachViews(); playerDisposed = true; } @@ -167,21 +174,40 @@ public void onMethodCall(MethodCall methodCall, @NonNull MethodChannel.Result re String initStreamURL = methodCall.argument("url"); Media media = new Media(libVLC, Uri.parse(initStreamURL)); - mediaPlayer.setMedia(media); + int hardwareAcceleration = Integer.parseInt((String) methodCall.argument("hwAcc")); + if (hardwareAcceleration != HW_ACCELERATION_AUTOMATIC) { + if (hardwareAcceleration == HW_ACCELERATION_DISABLED) { + System.out.println("HW_ACCELERATION Disabled"); + media.setHWDecoderEnabled(false, false); + } else if (hardwareAcceleration == HW_ACCELERATION_FULL || hardwareAcceleration == HW_ACCELERATION_DECODING) { + media.setHWDecoderEnabled(true, true); + if (hardwareAcceleration == HW_ACCELERATION_DECODING) { + System.out.println("HW_ACCELERATION Decoding"); + media.addOption(":no-mediacodec-dr"); + media.addOption(":no-omxil-dr"); + } else { + System.out.println("HW_ACCELERATION FULL"); + } + } + } else { + System.out.println("HW_ACCELERATION Automatic"); + } + media.addOption(":input-fast-seek"); + mediaPlayer.setMedia(media); result.success(null); break; case "dispose": this.dispose(); break; case "changeURL": - if(libVLC == null) result.error("VLC_NOT_INITIALIZED", "The player has not yet been initialized.", false); + if (libVLC == null) + result.error("VLC_NOT_INITIALIZED", "The player has not yet been initialized.", false); mediaPlayer.stop(); String newURL = methodCall.argument("url"); Media newMedia = new Media(libVLC, Uri.parse(newURL)); mediaPlayer.setMedia(newMedia); - result.success(null); break; case "getSnapshot": @@ -199,9 +225,9 @@ public void onMethodCall(MethodCall methodCall, @NonNull MethodChannel.Result re case "setPlaybackState": String playbackState = methodCall.argument("playbackState"); - if(playbackState == null) result.success(null); + if (playbackState == null) result.success(null); - switch(playbackState){ + switch (playbackState) { case "play": textureView.forceLayout(); mediaPlayer.play(); @@ -252,7 +278,7 @@ public void onEvent(MediaPlayer.Event event) { int width = 0; Media.VideoTrack currentVideoTrack = (Media.VideoTrack) mediaPlayer.getMedia().getTrack( - mediaPlayer.getVideoTrack() + mediaPlayer.getVideoTrack() ); if (currentVideoTrack != null) { height = currentVideoTrack.height; @@ -278,7 +304,7 @@ public void onEvent(MediaPlayer.Event event) { eventObject.put("value", false); eventObject.put("reason", "EndReached"); eventSink.success(eventObject); - + case MediaPlayer.Event.Vout: vout.setWindowSize(textureView.getWidth(), textureView.getHeight()); break; diff --git a/lib/flutter_vlc_player.dart b/lib/flutter_vlc_player.dart index e7df2b89..a2b973e8 100755 --- a/lib/flutter_vlc_player.dart +++ b/lib/flutter_vlc_player.dart @@ -9,6 +9,27 @@ import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; enum PlayingState { STOPPED, BUFFERING, PLAYING } +enum HwAcc { AUTO, DISABLED, DECODING, FULL } + +int getHwAcc({@required HwAcc hwAcc}) { + switch (hwAcc) { + case HwAcc.AUTO: + return -1; + break; + case HwAcc.DISABLED: + return 0; + break; + case HwAcc.DECODING: + return 1; + break; + case HwAcc.FULL: + return 2; + break; + default: + return -1; + break; + } +} class Size { final int width; @@ -23,6 +44,7 @@ class Size { class VlcPlayer extends StatefulWidget { final double aspectRatio; + final HwAcc hwAcc; final List options; final String url; final Widget placeholder; @@ -43,6 +65,9 @@ class VlcPlayer extends StatefulWidget { /// [VlcPlayerController.setStreamUrl] method so this can be changed at any time. @required this.url, + /// Set acceleration mode for player. Default is Auto. + this.hwAcc, + /// Adds options to vlc. For more [https://wiki.videolan.org/VLC_command-line_help] If nothing is provided, /// vlc will run without any options set. this.options, @@ -125,7 +150,7 @@ class _VlcPlayerState extends State // Once the controller has clients registered, we're good to register // with LibVLC on the platform side. if (_controller.hasClients) { - await _controller._initialize(widget.options, widget.url); + await _controller._initialize(widget.hwAcc, widget.options, widget.url); } } @@ -249,11 +274,15 @@ class VlcPlayerController { _eventHandlers.forEach((handler) => handler()); } - Future _initialize(List options, String url) async { + Future _initialize( + HwAcc hwAcc, List options, String url) async { //if(initialized) throw new Exception("Player already initialized!"); - await _methodChannel - .invokeMethod("initialize", {'url': url, 'options': options ?? []}); + await _methodChannel.invokeMethod("initialize", { + 'url': url, + 'hw_acc': getHwAcc(hwAcc: hwAcc), + 'options': options ?? [] + }); _position = 0; _eventChannel.receiveBroadcastStream().listen((event) { From cf72fd93e798e2afc4313759914fe690a03c94aa Mon Sep 17 00:00:00 2001 From: Harsh Date: Tue, 23 Jun 2020 14:05:59 +0530 Subject: [PATCH 09/13] fix channel arg mismatch; remove debug code --- .../fluttervlcplayer/FlutterVideoView.java | 23 ++++--------------- example/lib/main.dart | 1 + lib/flutter_vlc_player.dart | 4 ++-- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/android/src/main/java/software/solid/fluttervlcplayer/FlutterVideoView.java b/android/src/main/java/software/solid/fluttervlcplayer/FlutterVideoView.java index 32cfa6e2..3f3e6d91 100755 --- a/android/src/main/java/software/solid/fluttervlcplayer/FlutterVideoView.java +++ b/android/src/main/java/software/solid/fluttervlcplayer/FlutterVideoView.java @@ -152,15 +152,6 @@ public void onMethodCall(MethodCall methodCall, @NonNull MethodChannel.Result re } ArrayList options = methodCall.argument("options"); - // options.add("--no-drop-late-frames"); - // options.add("--no-skip-frames"); - // options.add("--rtsp-tcp"); - - // if(DISABLE_LOG_OUTPUT) { - // // Silence player log output. - // options.add("--quiet"); - // } - System.out.println("Adding VLC options: " + options); libVLC = new LibVLC(context, options); mediaPlayer = new MediaPlayer(libVLC); @@ -175,24 +166,18 @@ public void onMethodCall(MethodCall methodCall, @NonNull MethodChannel.Result re String initStreamURL = methodCall.argument("url"); Media media = new Media(libVLC, Uri.parse(initStreamURL)); - int hardwareAcceleration = Integer.parseInt((String) methodCall.argument("hwAcc")); - if (hardwareAcceleration != HW_ACCELERATION_AUTOMATIC) { + int hardwareAcceleration = methodCall.argument("hwAcc"); + if (hardwareAcceleration != HW_ACCELERATION_AUTOMATIC) if (hardwareAcceleration == HW_ACCELERATION_DISABLED) { - System.out.println("HW_ACCELERATION Disabled"); media.setHWDecoderEnabled(false, false); } else if (hardwareAcceleration == HW_ACCELERATION_FULL || hardwareAcceleration == HW_ACCELERATION_DECODING) { media.setHWDecoderEnabled(true, true); if (hardwareAcceleration == HW_ACCELERATION_DECODING) { - System.out.println("HW_ACCELERATION Decoding"); media.addOption(":no-mediacodec-dr"); media.addOption(":no-omxil-dr"); - } else { - System.out.println("HW_ACCELERATION FULL"); - } + } } - } else { - System.out.println("HW_ACCELERATION Automatic"); - } + media.addOption(":input-fast-seek"); mediaPlayer.setMedia(media); result.success(null); diff --git a/example/lib/main.dart b/example/lib/main.dart index 963342da..d1c312d4 100755 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -76,6 +76,7 @@ class MyAppScaffoldState extends State { '--no-skip-frames', '--rtsp-tcp' ], + hwAcc: HwAcc.DISABLED, // or {HwAcc.AUTO, HwAcc.DECODING, HwAcc.FULL} placeholder: Container( height: 250.0, child: Row( diff --git a/lib/flutter_vlc_player.dart b/lib/flutter_vlc_player.dart index a2b973e8..86074417 100755 --- a/lib/flutter_vlc_player.dart +++ b/lib/flutter_vlc_player.dart @@ -65,7 +65,7 @@ class VlcPlayer extends StatefulWidget { /// [VlcPlayerController.setStreamUrl] method so this can be changed at any time. @required this.url, - /// Set acceleration mode for player. Default is Auto. + /// Set hardware acceleration for player. Default is Automatic. this.hwAcc, /// Adds options to vlc. For more [https://wiki.videolan.org/VLC_command-line_help] If nothing is provided, @@ -280,7 +280,7 @@ class VlcPlayerController { await _methodChannel.invokeMethod("initialize", { 'url': url, - 'hw_acc': getHwAcc(hwAcc: hwAcc), + 'hwAcc': getHwAcc(hwAcc: hwAcc), 'options': options ?? [] }); _position = 0; From f9bd87d4e5cb520be07ddb6db3bb0cae25263d04 Mon Sep 17 00:00:00 2001 From: mitch ross Date: Tue, 7 Jul 2020 10:21:28 -0400 Subject: [PATCH 10/13] Create Video Seek Example --- example/android/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 4 +- example/lib/main.dart | 60 ++++++++++++++----- example/pubspec.yaml | 2 +- 4 files changed, 48 insertions(+), 20 deletions(-) diff --git a/example/android/build.gradle b/example/android/build.gradle index 91c94778..992f1a99 100755 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -5,7 +5,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.6.3' + classpath 'com.android.tools.build:gradle:4.0.0' } } diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 534fb274..486181e0 100755 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Mar 11 22:39:55 EDT 2020 +#Mon Jul 06 16:18:01 EDT 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/example/lib/main.dart b/example/lib/main.dart index 208f588c..f90850d5 100755 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:typed_data'; import 'package:flutter/material.dart'; @@ -28,6 +29,8 @@ class MyAppScaffoldState extends State { VlcPlayerController _videoViewController; VlcPlayerController _videoViewController2; bool isPlaying = true; + double sliderValue = 0.0; + double currentPlayerTime = 0; @override void initState() { @@ -45,6 +48,18 @@ class MyAppScaffoldState extends State { setState(() {}); }); + Timer.periodic(Duration(seconds: 1), (Timer timer) { + String state = _videoViewController2.playingState.toString(); + if (this.mounted) { + setState(() { + if (state == "PlayingState.PLAYING" && + sliderValue < _videoViewController2.duration.inSeconds) { + sliderValue = _videoViewController2.position.inSeconds.toDouble(); + } + }); + } + }); + super.initState(); } @@ -94,12 +109,26 @@ class MyAppScaffoldState extends State { ), ), ), - FlatButton( - child: isPlaying ? Icon(Icons.pause) : Icon(Icons.play_arrow) , - onPressed: () => { - playOrPauseVideo() - } + Slider( + activeColor: Colors.white, + value: sliderValue, + min: 0.0, + max: _videoViewController2.duration == null + ? 1.0 + : _videoViewController2.duration.inSeconds.toDouble(), + onChanged: (progress) { + setState(() { + sliderValue = progress.floor().toDouble(); + print('set state: $sliderValue'); + }); + print('set time: $sliderValue'); + //conver to Milliseconds since VLC requires MS to set time + _videoViewController2.setTime(sliderValue.toInt() * 1000); + }, ), + FlatButton( + child: isPlaying ? Icon(Icons.pause) : Icon(Icons.play_arrow), + onPressed: () => {playOrPauseVideo()}), FlatButton( child: Text("Change URL"), onPressed: () => _videoViewController.setStreamUrl( @@ -134,20 +163,19 @@ class MyAppScaffoldState extends State { } void playOrPauseVideo() { - String state = _videoViewController.playingState.toString(); - - if ( state == "PlayingState.PLAYING" ){ - _videoViewController.pause(); - setState(() { - isPlaying = false; - }); + String state = _videoViewController2.playingState.toString(); + + if (state == "PlayingState.PLAYING") { + _videoViewController2.pause(); + setState(() { + isPlaying = false; + }); } else { - _videoViewController.play(); - setState(() { + _videoViewController2.play(); + setState(() { isPlaying = true; - }); + }); } - } void _createCameraImage() async { diff --git a/example/pubspec.yaml b/example/pubspec.yaml index fcf9fd92..0e73202a 100755 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -3,7 +3,7 @@ description: Demonstrates how to use the flutter_vlc_player plugin. publish_to: 'none' environment: - sdk: ">=2.0.0-dev.68.0 <3.0.0" + sdk: ">=2.2.0 <3.0.0" dependencies: flutter: From 48db45c56397298db6cbaebce240cce7e0656f54 Mon Sep 17 00:00:00 2001 From: mitch Date: Tue, 7 Jul 2020 11:59:49 -0400 Subject: [PATCH 11/13] Fix seek time on iOS. Add Seekbar to demo app. --- CHANGELOG.md | 4 ++++ example/ios/Flutter/.last_build_id | 2 +- ios/Classes/SwiftFlutterVlcPlayerPlugin.swift | 7 +++++-- pubspec.yaml | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9e4a325..ee0ce971 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.0.3 +* Updates MobileVLC to fix a bug on ios with Seek Time. See (https://github.com/solid-software/flutter_vlc_player/issues/72). Also adds seek bar to example player for demonstration purposes. +credits to Mitch Ross (https://github.com/mitchross) + ## 3.0.2 * Updates MobileVLC to fix a bug on ios with HLS Streaming on VLCKit itself. See (https://code.videolan.org/videolan/VLCKit/-/issues/368), credits to Mitch Ross (https://github.com/mitchross) diff --git a/example/ios/Flutter/.last_build_id b/example/ios/Flutter/.last_build_id index 69faea91..536e0527 100755 --- a/example/ios/Flutter/.last_build_id +++ b/example/ios/Flutter/.last_build_id @@ -1 +1 @@ -9a6723ad18e3f950fccdc81adda11616 \ No newline at end of file +f1df2ffda6f2083c9121914530433089 \ No newline at end of file diff --git a/ios/Classes/SwiftFlutterVlcPlayerPlugin.swift b/ios/Classes/SwiftFlutterVlcPlayerPlugin.swift index b2a717ba..62a8036b 100755 --- a/ios/Classes/SwiftFlutterVlcPlayerPlugin.swift +++ b/ios/Classes/SwiftFlutterVlcPlayerPlugin.swift @@ -134,9 +134,12 @@ public class VLCView: NSObject, FlutterPlatformView { return case .setTime: - - let time = VLCTime(number: arguments["time"] as? NSNumber) + let setTimeInMillisecondsAsString = arguments["time"] as? String + let newTime = NSNumber(value:(setTimeInMillisecondsAsString! as NSString).doubleValue) + let time = VLCTime(number: newTime ) self.player.time = time + + result(nil) return diff --git a/pubspec.yaml b/pubspec.yaml index 8990e490..9efee0d2 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_vlc_player description: A VLC-powered alternative to Flutter's video_player. Supports multiple players on one screen. -version: 3.0.2 +version: 3.0.3 homepage: https://github.com/solid-software/flutter_vlc_player environment: From 29ef030f4ffea652d49237ce2a1f8ed65cf103c9 Mon Sep 17 00:00:00 2001 From: mitch ross Date: Wed, 8 Jul 2020 17:16:51 -0400 Subject: [PATCH 12/13] PR comments --- CHANGELOG.md | 4 ++-- example/lib/main.dart | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee0ce971..53a9e571 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,9 @@ ## 3.0.3 -* Updates MobileVLC to fix a bug on ios with Seek Time. See (https://github.com/solid-software/flutter_vlc_player/issues/72). Also adds seek bar to example player for demonstration purposes. +* Updates MobileVLC to fix a bug on iOS with Seek Time. See (https://github.com/solid-software/flutter_vlc_player/issues/72). Also adds seek bar to example player for demonstration purposes. credits to Mitch Ross (https://github.com/mitchross) ## 3.0.2 -* Updates MobileVLC to fix a bug on ios with HLS Streaming on VLCKit itself. See (https://code.videolan.org/videolan/VLCKit/-/issues/368), +* Updates MobileVLC to fix a bug on iOS with HLS Streaming on VLCKit itself. See (https://code.videolan.org/videolan/VLCKit/-/issues/368), credits to Mitch Ross (https://github.com/mitchross) ## 3.0.1 diff --git a/example/lib/main.dart b/example/lib/main.dart index f90850d5..bf5646a1 100755 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -119,10 +119,8 @@ class MyAppScaffoldState extends State { onChanged: (progress) { setState(() { sliderValue = progress.floor().toDouble(); - print('set state: $sliderValue'); }); - print('set time: $sliderValue'); - //conver to Milliseconds since VLC requires MS to set time + //convert to Milliseconds since VLC requires MS to set time _videoViewController2.setTime(sliderValue.toInt() * 1000); }, ), From 175ebe8eb1ec43a29ae00fd37edc22e92d9b711f Mon Sep 17 00:00:00 2001 From: mitch ross Date: Thu, 30 Jul 2020 16:04:55 -0400 Subject: [PATCH 13/13] latest master code, plus minor tweaks. latest master code, plus minor tweaks. --- CHANGELOG.md | 4 ++++ example/lib/main.dart | 4 ++-- example/pubspec.yaml | 2 +- lib/flutter_vlc_player.dart | 8 +++----- pubspec.yaml | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53a9e571..893da3bb 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.0.4 +* Updates MobileVLC to allow for options as flags and hardware acceleration/ +credits to pharshdev (https://github.com/pharshdev) and Mitch Ross (https://github.com/mitchross) + ## 3.0.3 * Updates MobileVLC to fix a bug on iOS with Seek Time. See (https://github.com/solid-software/flutter_vlc_player/issues/72). Also adds seek bar to example player for demonstration purposes. credits to Mitch Ross (https://github.com/mitchross) diff --git a/example/lib/main.dart b/example/lib/main.dart index 4d84395a..25e13e89 100755 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -82,7 +82,7 @@ class MyAppScaffoldState extends State { child: new VlcPlayer( aspectRatio: 16 / 9, url: - "http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_60fps_normal.mp4", + "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerJoyrides.mp4", controller: _videoViewController, // Play with vlc options options: [ @@ -106,7 +106,7 @@ class MyAppScaffoldState extends State { child: new VlcPlayer( aspectRatio: 16 / 9, url: - "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerJoyrides.mp4", + "http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_60fps_normal.mp4", controller: _videoViewController2, placeholder: Container( height: 250.0, diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 0e73202a..004c97f4 100755 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^0.1.2 + cupertino_icons: ^0.1.3 dev_dependencies: flutter_test: diff --git a/lib/flutter_vlc_player.dart b/lib/flutter_vlc_player.dart index 9f5c0661..3927d5dd 100755 --- a/lib/flutter_vlc_player.dart +++ b/lib/flutter_vlc_player.dart @@ -13,9 +13,6 @@ enum HwAcc { AUTO, DISABLED, DECODING, FULL } int getHwAcc({@required HwAcc hwAcc}) { switch (hwAcc) { - case HwAcc.AUTO: - return -1; - break; case HwAcc.DISABLED: return 0; break; @@ -25,6 +22,7 @@ int getHwAcc({@required HwAcc hwAcc}) { case HwAcc.FULL: return 2; break; + case HwAcc.AUTO: default: return -1; break; @@ -151,7 +149,7 @@ class _VlcPlayerState extends State // Once the controller has clients registered, we're good to register // with LibVLC on the platform side. if (_controller.hasClients) { - await _controller._initialize(widget.hwAcc, widget.options, widget.url); + await _controller._initialize( widget.url,widget.hwAcc, widget.options,); } } @@ -276,7 +274,7 @@ class VlcPlayerController { } Future _initialize( - HwAcc hwAcc, List options, String url) async { + String url,[HwAcc hwAcc, List options]) async { //if(initialized) throw new Exception("Player already initialized!"); await _methodChannel.invokeMethod("initialize", { diff --git a/pubspec.yaml b/pubspec.yaml index 9efee0d2..7c22b358 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_vlc_player description: A VLC-powered alternative to Flutter's video_player. Supports multiple players on one screen. -version: 3.0.3 +version: 3.0.4 homepage: https://github.com/solid-software/flutter_vlc_player environment: