Skip to content
Merged
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
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.3.7
version: 1.3.8

environment:
sdk: '>=3.0.0 <4.0.0'
Expand Down
4 changes: 4 additions & 0 deletions lib/src/widgets/media/carousel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import 'package:likeminds_feed/likeminds_feed.dart';
import 'package:likeminds_feed_ui_fl/src/utils/theme.dart';
import 'package:likeminds_feed_ui_fl/src/widgets/media/image.dart';
import 'package:likeminds_feed_ui_fl/src/widgets/media/video.dart';
import 'package:media_kit_video/media_kit_video.dart';

class LMCarousel extends StatefulWidget {
final List<Attachment> attachments;
final Function(VideoController)? initialiseVideoController;

final double? height;
final double? width;
Expand Down Expand Up @@ -40,6 +42,7 @@ class LMCarousel extends StatefulWidget {
this.inactiveIndicatorColor,
this.errorWidget,
this.boxFit,
this.initialiseVideoController,
}) : super(key: key);

@override
Expand Down Expand Up @@ -85,6 +88,7 @@ class _LMCarouselState extends State<LMCarousel> {
width: MediaQuery.of(context).size.width,
child: widget.videoItem ??
LMVideo(
initialiseVideoController: widget.initialiseVideoController,
videoUrl: e.attachmentMeta.url,
width: widget.width,
height: widget.height,
Expand Down
25 changes: 15 additions & 10 deletions lib/src/widgets/media/video.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import 'dart:async';
import 'dart:io';

// import 'package:flick_video_player/flick_video_player.dart';
import 'package:flutter/material.dart';
import 'package:likeminds_feed_ui_fl/likeminds_feed_ui_fl.dart';
import 'package:likeminds_feed_ui_fl/src/utils/theme.dart';
import 'package:likeminds_feed_ui_fl/src/widgets/common/buttons/icon_button.dart';
import 'package:likeminds_feed_ui_fl/src/widgets/common/shimmer/post_shimmer.dart';
import 'package:media_kit/media_kit.dart';
import 'package:media_kit_video/media_kit_video.dart';
import 'package:visibility_aware_state/visibility_aware_state.dart';
import 'package:visibility_detector/visibility_detector.dart';
import 'package:media_kit_video/media_kit_video_controls/media_kit_video_controls.dart'
as media_kit_video_controls;
import 'package:visibility_aware_state/visibility_aware_state.dart';

class LMVideo extends StatefulWidget {
// late final LMVideo? _instance;
Expand Down Expand Up @@ -43,12 +42,15 @@ class LMVideo extends StatefulWidget {
this.progressTextStyle,
this.seekBarBufferColor,
this.seekBarColor,
this.initialiseVideoController,
}) : assert(videoUrl != null || videoFile != null);

//Video asset variables
final String? videoUrl;
final File? videoFile;

final Function(VideoController)? initialiseVideoController;

// Video structure variables
final double? height;
final double? width;
Expand Down Expand Up @@ -108,6 +110,12 @@ class _LMVideoState extends VisibilityAwareState<LMVideo> {
initialiseController = initialiseControllers();
}

@override
void initState() {
super.initState();
initialiseController = initialiseControllers();
}

@override
void onVisibilityChanged(WidgetVisibility visibility) {
// TODO: Use visibility
Expand All @@ -119,11 +127,6 @@ class _LMVideoState extends VisibilityAwareState<LMVideo> {
super.onVisibilityChanged(visibility);
}

@override
void initState() {
super.initState();
initialiseController = initialiseControllers();
}

Future<void> initialiseControllers() async {
player = Player(
Expand All @@ -141,6 +144,9 @@ class _LMVideoState extends VisibilityAwareState<LMVideo> {
scale: 0.2,
),
);
if(widget.initialiseVideoController != null){
widget.initialiseVideoController!(controller!);
}
if (widget.videoUrl != null) {
await player.open(
Media(widget.videoUrl!),
Expand Down Expand Up @@ -177,14 +183,13 @@ class _LMVideoState extends VisibilityAwareState<LMVideo> {
return Stack(children: [
VisibilityDetector(
key: ObjectKey(player),
//Key('post_video_${widget.videoUrl ?? widget.videoFile}'),
onVisibilityChanged: (visibilityInfo) async {
var visiblePercentage =
visibilityInfo.visibleFraction * 100;
if (visiblePercentage < 100) {
if (visiblePercentage <= 70) {
controller?.player.pause();
}
if (visiblePercentage == 100) {
if (visiblePercentage > 70) {
controller?.player.play();
rebuildOverlay.value = !rebuildOverlay.value;
}
Expand Down
4 changes: 4 additions & 0 deletions lib/src/widgets/post/post_media.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:likeminds_feed/likeminds_feed.dart';
import 'package:likeminds_feed_ui_fl/likeminds_feed_ui_fl.dart';
import 'package:media_kit_video/media_kit_video.dart';
import 'package:url_launcher/url_launcher.dart';

class LMPostMedia extends StatefulWidget {
Expand All @@ -21,9 +22,11 @@ class LMPostMedia extends StatefulWidget {
this.errorWidget,
this.boxFit,
this.textColor,
this.initialiseVideoController,
});

final List<Attachment> attachments;
final Function(VideoController)? initialiseVideoController;
final Widget? documentIcon;
final double? borderRadius;
final double? width;
Expand Down Expand Up @@ -87,6 +90,7 @@ class _LMPostMediaState extends State<LMPostMedia> {
);
} else {
return LMCarousel(
initialiseVideoController: widget.initialiseVideoController,
attachments: attachments!,
borderRadius: widget.borderRadius,
activeIndicatorColor: widget.carouselActiveIndicatorColor,
Expand Down
82 changes: 9 additions & 73 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,26 @@ packages:
dependency: "direct main"
description:
name: cached_network_image
sha256: fd3d0dc1d451f9a252b32d95d3f0c3c487bc41a75eba2e6097cb0b9c71491b15
sha256: f98972704692ba679db144261172a8e20feb145636c617af0eb4022132a6797f
url: "https://pub.dev"
source: hosted
version: "3.3.0"
cached_network_image_platform_interface:
dependency: transitive
description:
name: cached_network_image_platform_interface
sha256: bb2b8403b4ccdc60ef5f25c70dead1f3d32d24b9d6117cfc087f496b178594a7
sha256: "56aa42a7a01e3c9db8456d9f3f999931f1e05535b5a424271e9a38cabf066613"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
version: "3.0.0"
cached_network_image_web:
dependency: transitive
description:
name: cached_network_image_web
sha256: b8eb814ebfcb4dea049680f8c1ffb2df399e4d03bf7a352c775e26fa06e02fa0
sha256: "759b9a9f8f6ccbb66c185df805fac107f05730b1dab9c64626d1008cca532257"
url: "https://pub.dev"
source: hosted
version: "1.0.2"
version: "1.1.0"
carousel_slider:
dependency: "direct main"
description:
Expand Down Expand Up @@ -145,14 +145,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.0.3"
csslib:
dependency: transitive
description:
name: csslib
sha256: "706b5707578e0c1b4b7550f64078f0a0f19dec3f50a178ffae7006b0a9ca58fb"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
curl_logger_dio_interceptor:
dependency: transitive
description:
Expand Down Expand Up @@ -246,14 +238,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_blurhash:
dependency: transitive
description:
name: flutter_blurhash
sha256: "05001537bd3fac7644fa6558b09ec8c0a3f2eba78c0765f88912882b1331a5c6"
url: "https://pub.dev"
source: hosted
version: "0.7.0"
flutter_cache_manager:
dependency: transitive
description:
Expand Down Expand Up @@ -312,14 +296,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.2"
html:
dependency: transitive
description:
name: html
sha256: "3a7812d5bcd2894edf53dfaf8cd640876cf6cef50a8f238745c8b8120ea74d3a"
url: "https://pub.dev"
source: hosted
version: "0.15.4"
http:
dependency: "direct main"
description:
Expand Down Expand Up @@ -388,10 +364,10 @@ packages:
dependency: "direct main"
description:
name: likeminds_feed
sha256: f630ed3d36002bb67f9eacf3016a8e7deee942f0ee76b932a9135abe4e686d06
sha256: e47b77e3eadfc475cd62e9bc1ea9c76fb64b5a3dc9cdb548782b06423f7c8e28
url: "https://pub.dev"
source: hosted
version: "1.4.1"
version: "1.6.3"
lints:
dependency: transitive
description:
Expand Down Expand Up @@ -508,10 +484,10 @@ packages:
dependency: transitive
description:
name: octo_image
sha256: "107f3ed1330006a3bea63615e81cf637433f5135a52466c7caa0e7152bca9143"
sha256: "45b40f99622f11901238e18d48f5f12ea36426d8eced9f4cbf58479c7aa2430d"
url: "https://pub.dev"
source: hosted
version: "1.0.2"
version: "2.0.0"
open_filex:
dependency: "direct main"
description:
Expand Down Expand Up @@ -965,46 +941,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
video_player:
dependency: "direct main"
description:
name: video_player
sha256: d3910a8cefc0de8a432a4411dcf85030e885d8fef3ddea291f162253a05dbf01
url: "https://pub.dev"
source: hosted
version: "2.7.1"
video_player_android:
dependency: transitive
description:
name: video_player_android
sha256: "3fe89ab07fdbce786e7eb25b58532d6eaf189ceddc091cb66cba712f8d9e8e55"
url: "https://pub.dev"
source: hosted
version: "2.4.10"
video_player_avfoundation:
dependency: transitive
description:
name: video_player_avfoundation
sha256: c3b123a5a56c9812b9029f840c65b92fd65083eb08d69be016b01e8aa018f77d
url: "https://pub.dev"
source: hosted
version: "2.4.10"
video_player_platform_interface:
dependency: transitive
description:
name: video_player_platform_interface
sha256: be72301bf2c0150ab35a8c34d66e5a99de525f6de1e8d27c0672b836fe48f73a
url: "https://pub.dev"
source: hosted
version: "6.2.1"
video_player_web:
dependency: transitive
description:
name: video_player_web
sha256: "9c34a243785feca23148bfcd772dbb803d63c9304488177ec4f3f4463802fcb7"
url: "https://pub.dev"
source: hosted
version: "2.0.17"
visibility_detector:
dependency: "direct main"
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: likeminds_feed_ui_fl
description: A Flutter package for Likeminds Feed UI widgets. Used alongside the Likeminds Feed SDK package (likeminds_feed) to build custom interfaces.
version: 1.3.7
version: 1.3.8
publish_to: none
homepage: "www.likeminds.community/"

Expand Down