Closed DomingoMG closed 3 years ago
What’s wrong with using a timer?
This is really beyond the scope of project. You can yourself handle this within dart. Our wrapper is already a good high-level abstraction upon libVLC API.
Using the existing methods does not allow me to fast-forward the audio without playing it back. I feel compelled to play the music to use player.seek (Duration ()); From my point of view, using a timer does not seem correct, I am just trying to provide new tools that various users would need.
It does not work to fast-forward the audio without actually playing it.
Player player = Player(id: 1);
@override
void initState() {
player.open(
Media.file(File('C:\\audios\\Pop\\music1.mp3')),
autoStart: false
);
player.seek(Duration(seconds: 30));
super.initState();
}
Sry, I didn’t get it yet. You want to open a file, seek to a certain position without playing it and once you invoke play
, it should play from the previously seeked position?
@jnschulze Exactly.
And what happens upon invoking play then? Does it play from the beginning?
@jnschulze After instantiating the open and seek () play is not working.
@DomingoMG
I was able to reproduce this and have the same issue. It only works when adding a small delay after opening the video and before invoking seek
. Probably because the player API pretends that it's synchronous, however, this doesn't mean that VLC has completed an internal operation when a Player
method like seek
, pause
etc. returns.
So you'll need to wait for a media item to be loaded before seeking.
@alexmercerind, I guess we should expose libvlc_MediaPlayerBuffering to the dart side.
@DomingoMG so, I have added this to Media
itself. Since, thats how libVLC API also has it.
@zezo357 you might be also interested in the same.
// Clip the media.
Media media2 = Media.network(
'https://www.example.com/music.aac',
startTime: Duration(seconds: 20), // Start media from 20 seconds from the beginning.
stopTime: Duration(seconds: 60), // End media at 60 seconds from the beginning.
);
Another change is that minimum required Flutter version is now 2.2. However, latest texture update for Linux will only work on master channel as of now.
@DomingoMG so, I have added this to
Media
itself. Since, thats how libVLC API also has it. @zezo357 you might be also interested in the same.// Clip the media. Media media2 = Media.network( 'https://www.example.com/music.aac', startTime: Duration(seconds: 20), // Start media from 20 seconds from the beginning. stopTime: Duration(seconds: 60), // End media at 60 seconds from the beginning. );
Another change is that minimum required Flutter version is now 2.2. However, latest texture update for Linux will only work on master channel as of now.
Does the video player works If seek is called before it's loaded?
In my case the code checks the database to seek to the last watched time when the video is loading to make it faster since the video loading and database checking takes some time
For my fix When seek is called and duration is zero in seconds
I made a timer that will check each 500 millisecond that the video duration is not zero if it's not zero will seek and cancel the timer
That works well in my case I hope it can help
my code
if(duration.value.inSeconds!=0){
_videoPlayerControllerWindows?.seek(position);
}else {
_timerForSeek?.cancel();
_timerForSeek =Timer.periodic(Duration(milliseconds: 500), (Timer t) async {
if (duration.value.inSeconds != 0) {
_videoPlayerControllerWindows?.seek(position);
t.cancel();
_timerForSeek = null;
}
});
}
@DomingoMG so, I have added this to
Media
itself. Since, thats how libVLC API also has it. @zezo357 you might be also interested in the same.// Clip the media. Media media2 = Media.network( 'https://www.example.com/music.aac', startTime: Duration(seconds: 20), // Start media from 20 seconds from the beginning. stopTime: Duration(seconds: 60), // End media at 60 seconds from the beginning. );
Another change is that minimum required Flutter version is now 2.2. However, latest texture update for Linux will only work on master channel as of now.
Does the video player works If seek is called before it's loaded?
In my case the code checks the database to seek to the last watched time when the video is loading to make it faster since the video loading and database checking takes some time
For my fix When seek is called and duration is zero in seconds
I made a timer that will check each 500 millisecond that the video duration is not zero if it's not zero will seek and cancel the timer
That works well in my case I hope it can help
@zezo357 , for resuming your Media
from the last watched time, you should pass the startTime
when creating the Media
. You cannot unfortunately seek before playing the Media
& that's a constraint of how libVLC API is made. I tried to add seek
call after isPlaying
event in libVLC++, but it didn't work either. So, these :start-time
& :stop-time
arguments are something that are part of libVLC itself & work well (and officially supported).
@DomingoMG so, I have added this to
Media
itself. Since, thats how libVLC API also has it. @zezo357 you might be also interested in the same.// Clip the media. Media media2 = Media.network( 'https://www.example.com/music.aac', startTime: Duration(seconds: 20), // Start media from 20 seconds from the beginning. stopTime: Duration(seconds: 60), // End media at 60 seconds from the beginning. );
Another change is that minimum required Flutter version is now 2.2. However, latest texture update for Linux will only work on master channel as of now.
Does the video player works If seek is called before it's loaded?
In my case the code checks the database to seek to the last watched time when the video is loading to make it faster since the video loading and database checking takes some time
For my fix When seek is called and duration is zero in seconds
I made a timer that will check each 500 millisecond that the video duration is not zero if it's not zero will seek and cancel the timer
That works well in my case I hope it can help
@zezo357 , for resuming your
Media
from the last watched time, you should pass thestartTime
.
But that will require me to check database before running the open function which will increase the time of waiting for the user watching
For me the timer solution is good enough I just wanted to share it if anyone wanted it
For me the timer solution is good enough I just wanted to share it if anyone wanted it
It's fine. However, event polling isn't the best option that I can include "officially" within the plugin. I don't know how it is any better compared to startTime
.
For me the timer solution is good enough I just wanted to share it if anyone wanted it
It's fine. However, event polling isn't the best option that I can include "officially" within the plugin. I don't know how it is any better compared to
startTime
.
Will test it,Since you know better
Thanks for your work, sorry for taking your time
@alexmercerind I tested the start time
but sometimes the video player gets black screen while sound and position works and sometimes the old bug happens that the video doesn't load
I cant find the cause of the problem sadly
@zezo357 I'm using CarouselSlider when it slide.. it go black screen.. but i hear sound
@zezo357 I'm using CarouselSlider when it slide.. it go black screen.. but i hear sound
For me it was black screen and no sound
So I did use my timer code and it never happened again for me.
It would be interesting to incorporate a variable called start at.