You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The tweets with video embedded are hardcoded to start with a 0.0 volume, I found in this file:
lib/src/tweet_video.dart
Is there a possibility to add an option to set a default initial volume?
I think it would be possible by adding to TweetView class a new double property, then passing it to MediaContainer and finally to TweetVideo. At least it looks so much straight forward than add a way to access the Chewie controller.
Thank you so much! (again)
I think this could be done in this dirty way:
diff --git a/lib/src/media_container.dart b/lib/src/media_container.dart
index f4876d5..fc17564 100644
--- a/lib/src/media_container.dart+++ b/lib/src/media_container.dart@@ -19,12 +19,14 @@ class MediaContainer extends StatefulWidget {
this.viewMode, {
Key key,
this.useVideoPlayer = true,
+ this.videoPlayerInitialVolume = 0.0,
this.onTapImage,
}) : super(key: key);
final TweetVM tweetVM;
final ViewMode viewMode;
final bool useVideoPlayer;
+ final double videoPlayerInitialVolume;
@override
_MediaContainerState createState() => _MediaContainerState();
@@ -47,7 +49,10 @@ class _MediaContainerState extends State<MediaContainer>
Widget child;
if (widget.tweetVM.getDisplayTweet().hasSupportedVideo) {
if (widget.useVideoPlayer) {
- child = TweetVideo(widget.tweetVM.getDisplayTweet());+ child = TweetVideo(+ widget.tweetVM.getDisplayTweet(),+ initialVolume: widget.videoPlayerInitialVolume+ );
} else {
child = Stack(
children: <Widget>[
diff --git a/lib/src/tweet_video.dart b/lib/src/tweet_video.dart
index b7ace27..a85ae36 100644
--- a/lib/src/tweet_video.dart+++ b/lib/src/tweet_video.dart@@ -9,9 +9,11 @@ class TweetVideo extends StatefulWidget {
TweetVideo(
this.tweetVM, {
Key key,
+ this.initialVolume = 0.0
}) : super(key: key);
final TweetVM tweetVM;
+ final double initialVolume;
@override
_TweetVideoState createState() => _TweetVideoState();
@@ -27,7 +29,7 @@ class _TweetVideoState extends State<TweetVideo>
super.initState();
_controller = VideoPlayerController.network(
widget.tweetVM.getDisplayTweet().videoUrl);
- _controller.setVolume(0.0);+ _controller.setVolume(widget.initialVolume);
_chewieController = ChewieController(
videoPlayerController: _controller,
diff --git a/lib/tweet_view.dart b/lib/tweet_view.dart
index 660b3bc..4b32fa3 100644
--- a/lib/tweet_view.dart+++ b/lib/tweet_view.dart@@ -58,6 +58,9 @@ class TweetView extends StatelessWidget {
/// If set to false a image placeholder will he shown and a video will be played in a new page.
final bool useVideoPlayer;
+ /// If the Tweet contains a video then an initial volume can be specified with a value between 0.0 and 1.0.+ final double videoPlayerInitialVolume;+
/// Function used when you want a custom image tapped callback
final OnTapImage onTapImage;
@@ -79,6 +82,7 @@ class TweetView extends StatelessWidget {
this.quoteBackgroundColor,
this.backgroundColor,
this.useVideoPlayer,
+ this.videoPlayerInitialVolume,
this.onTapImage,
this.createdDateDisplayFormat,
}); // TweetView(this.tweetVM);
@@ -97,6 +101,7 @@ class TweetView extends StatelessWidget {
this.quoteBackgroundColor = Colors.white,
this.backgroundColor = Colors.white,
this.useVideoPlayer = true,
+ this.videoPlayerInitialVolume = 0.0,
this.onTapImage,
this.createdDateDisplayFormat})
: _tweetVM = TweetVM.fromApiModel(tweet, createdDateDisplayFormat);
@@ -111,6 +116,7 @@ class TweetView extends StatelessWidget {
_tweetVM,
ViewMode.standard,
useVideoPlayer: useVideoPlayer,
+ videoPlayerInitialVolume: videoPlayerInitialVolume,
onTapImage: onTapImage,
),
GestureDetector(
The text was updated successfully, but these errors were encountered:
The tweets with video embedded are hardcoded to start with a 0.0 volume, I found in this file:
Is there a possibility to add an option to set a default initial volume?
I think it would be possible by adding to
TweetView
class a new double property, then passing it toMediaContainer
and finally toTweetVideo
. At least it looks so much straight forward than add a way to access the Chewie controller.Thank you so much! (again)
I think this could be done in this dirty way:
The text was updated successfully, but these errors were encountered: