-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Enable playing video from local asset. #437
Conversation
b328198
to
b1482ad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -31,12 +32,45 @@ | |||
private final EventChannel eventChannel; | |||
private boolean isInitialized = false; | |||
|
|||
|
|||
VideoPlayer( | |||
final EventChannel eventChannel, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of these parameters need to be final
. Same in the other constructor.
|
||
class _NetworkPlayerLifeCycleState extends _PlayerLifeCycleState { | ||
|
||
_NetworkPlayerLifeCycleState(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant
|
||
class _AssetPlayerLifeCycleState extends _PlayerLifeCycleState { | ||
|
||
_AssetPlayerLifeCycleState(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant
[registrar addMethodCallDelegate:instance channel:channel]; | ||
} | ||
|
||
- (instancetype)initWithRegistry:(NSObject<FlutterTextureRegistry>*)registry | ||
messenger:(NSObject<FlutterBinaryMessenger>*)messenger { | ||
messenger:(NSObject<FlutterBinaryMessenger>*)messenger | ||
registrar:(NSObject<FlutterPluginRegistrar>*)registrar { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe reduce parameters to just the registrar
, then access the FlutterBinaryMessenger
and the FlutterTextureRegistry
from there.
if (dataSource) { | ||
NSString* assetPath = [_registrar lookupKeyForAsset:dataSource]; | ||
player = [[FLTVideoPlayer alloc] initWithAsset:assetPath | ||
frameUpdater:frameUpdater]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reformat?
Timer timer; | ||
bool isDisposed = false; | ||
Completer<Null> _creatingCompleter; | ||
StreamSubscription<dynamic> _eventSubscription; | ||
_VideoAppLifeCycleObserver _lifeCycleObserver; | ||
dynamic _createMethodArg; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a bit sad that we need to carry this map around for the lifetime of the controller, given that it is only used during initialization. What about having final String dataSource
and final bool isNetwork
fields instead? Those may be useful for other purposes. Error reporting on playback failure should be very different for a network datasource compared to an asset one.
FYI: this PR came up in a Reddit thread here: https://www.reddit.com/r/FlutterDev/comments/87qqn2/has_anyone_used_video_in_an_app/ :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
0e04e1c
to
c176c1a
Compare
c176c1a
to
9466d55
Compare
I gave a hand to @osorito who is using windows and could try version 0.3.0 of video player plugin but not on version 0.4.0.
Both versions work for me on OS X, although I'm using Our Dart code is different, we tried to follow from the examples published on github but independently. Only difference in dart from v 0.3.0 to 0.4.0 was from I'm not sure this is the place for this kind of problem reporting but I couldn't open a new issue. Also I'm not sure how to track the code for this change, my educated guess is that he's not bringing flutter.jar with his gradle configuration. That said I don't know how to find the commit for version 0.3.0 / 0.4.0 and have a look at all the changes. I've also heard from other people in gitter having problems in java / swift compiling when importing different packages, is there a documentation where I can understand the configuration for gradle / pods (?) and how they bring flutter code into native projects so build tools find them? |
This is the change that made it work under version 0.3.0 class _NetworkPlayerLifeCycleState extends _PlayerLifeCycleState { class _AssetPlayerLifeCycleState extends _PlayerLifeCycleState { |
This is my flutter doctor result C:\Users\Omar Osorio\AndroidStudioProjects\flutter_video_example>flutter doctor • No issues found! Since i'm using Android Studio 3.1 in my graddle propperties #Fri Jun 23 08:50:38 CEST 2017 And my build graddle dependencies { |
I found the problem, That's completely understandable since it's both backwards compatible and you guys are entitled to API changes while in beta. But please understand that this strongly affects the perception of stability of the build system. It would be nice to have a note added to this plugin such as "Use flutter 0.2.x or later". |
Thanks for diving into this. Yes, the |
Using Chewie video player can I play video from local storage? For example, I want to download video from network and save to device and want to play in apps by Chewie video player. Is it possible? async { Want to open this video file into Chewie video player. |
No description provided.