Skip to content

Commit

Permalink
Merge pull request alexmercerind#159 from krjw-eyev/fix-media-and-clo…
Browse files Browse the repository at this point in the history
…sing

fixed media parse & fixed bug when closing video
  • Loading branch information
krjw-eyev authored Sep 14, 2021
2 parents 2a7c7f7 + 1470de4 commit 3f8c73d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
4 changes: 2 additions & 2 deletions example/macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos

SPEC CHECKSUMS:
dart_vlc: 658d094d047363f415eff6aa093507dbf6fc6a9c
dart_vlc: 712bcba43dcadeecae75c5951b0cfec656e525b4
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
path_provider_macos: a0a3fd666cb7cd0448e936fb4abad4052961002b
VLCKit: 21651e881f19774ecf9a86ca2c2010859fe68a08

PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c

COCOAPODS: 1.10.2
COCOAPODS: 1.11.0
2 changes: 2 additions & 0 deletions example/windows/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Generated file. Do not edit.
//

// clang-format off

#include "generated_plugin_registrant.h"

#include <dart_vlc/dart_vlc_plugin.h>
Expand Down
2 changes: 2 additions & 0 deletions example/windows/flutter/generated_plugin_registrant.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Generated file. Do not edit.
//

// clang-format off

#ifndef GENERATED_PLUGIN_REGISTRANT_
#define GENERATED_PLUGIN_REGISTRANT_

Expand Down
13 changes: 8 additions & 5 deletions ffi/lib/src/mediaSource/media.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ class Media implements MediaSource {
final Map<String, String> metas;

const Media._(
{required this.mediaType, required this.resource, this.metas = const {}});
{required this.mediaType, required this.resource, required this.metas});

/// Makes [Media] object from a [File].
static Media file(File file,
{bool parse: false,
Map<String, dynamic>? extras,
Duration timeout: const Duration(seconds: 10)}) {
final media = Media._(mediaType: MediaType.file, resource: file.path);
final media =
Media._(mediaType: MediaType.file, resource: file.path, metas: {});

if (parse) {
media.parse(timeout);
Expand All @@ -55,7 +56,7 @@ class Media implements MediaSource {
Duration timeout: const Duration(seconds: 10)}) {
final resource = (url is Uri) ? url.toString() : url;
final Media media =
Media._(mediaType: MediaType.network, resource: resource);
Media._(mediaType: MediaType.network, resource: resource, metas: {});

if (parse) {
media.parse(timeout);
Expand All @@ -78,7 +79,8 @@ class Media implements MediaSource {
'live-caching': liveCaching
});

return Media._(mediaType: MediaType.directShow, resource: resourceUrl);
return Media._(
mediaType: MediaType.directShow, resource: resourceUrl, metas: {});
}

/// Makes [Media] object from assets.
Expand Down Expand Up @@ -121,7 +123,8 @@ class Media implements MediaSource {
throw UnimplementedError('The platform is not supported');
}
final url = Uri.file(assetPath, windows: Platform.isWindows);
return Media._(mediaType: MediaType.asset, resource: url.toString());
return Media._(
mediaType: MediaType.asset, resource: url.toString(), metas: {});
}

/// Parses the [Media] to retrieve [Media.metas].
Expand Down
6 changes: 4 additions & 2 deletions lib/src/widgets/controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@ class ControlState extends State<Control> with SingleTickerProviderStateMixin {
@override
void dispose() {
playPauseStream.cancel();
playPauseController.dispose();
super.dispose();
}

void setPlaybackMode(bool isPlaying) {
if (isPlaying)
if (isPlaying) {
playPauseController.forward();
else
} else {
playPauseController.reverse();
}
setState(() {});
}

Expand Down
3 changes: 2 additions & 1 deletion lib/src/widgets/video.dart
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ class _VideoStateFallback extends _VideoStateBase {
?.stream
.listen((VideoFrame videoFrame) async {
videoFrameRawImage = await getVideoFrameRawImage(videoFrame);
if (mounted) setState(() {});
if (mounted && !(videoStreamControllers[playerId]?.isClosed ?? true))
setState(() {});
});
super.initState();
if (mounted) setState(() {});
Expand Down

0 comments on commit 3f8c73d

Please sign in to comment.