Comments (12)
A couple of tweaks but this is now working perfectly. Thanks for the hints.
private void LoadVideo()
{
// Open the stream and immediately get a snapshot at the 3sec mark
flPlayer.SeekCompleted += FLPlayer_SeekCompleted;
flPlayer.OpenCompleted += (o, e) =>
{
if (!e.Success) return;
flPlayer.SeekAccurate(3000);
};
flPlayer.OpenAsync(SampleVideo);
}
private void FLPlayer_SeekCompleted(object sender, int e)
{
flPlayer.SeekCompleted -= FLPlayer_SeekCompleted;
if (e == -1) return;
pbSnapshot.Image = flVideo.Player.TakeSnapshotToBitmap();
flPlayer.Seek(0);
}
from flyleaf.
Hi @davsun55 and thanks!
I know that the documentation requires more work that's why I tried to include more samples/tests and also check XML documentation/comments.
-
Not sure what you want to do here (you can SeekAccurate to 2sec and then use TakeSnapshotToFile/TakeSnapshotToBitmap) or use PropertyChanged for CurTime and check when the current time is 2sec?
-
Stop should work like that (closing the input and clears the frame). What you need is to Pause and Seek(0).
-
Seek will seek at a keyframe (this means that it will not be accurate, depends from the video's GOP size) but it will be faster while SeekAccurate will be accurate but slower (as it needs to decode all the GOP frames until the actual timestamp). SeekBackward(2/3) and SeekForward(2/3) will use Seek or SeekAccurate based on Config.Player.SeekAccurate and the time offsets based on Config.Player.SeekOffset(2/3)
-
Don't use this, always use the Player Set/Seek time and then use this without a frame (to get the current one)
Feel free to ask for more details
John
from flyleaf.
from flyleaf.
@davsun55 You just found some issues here I guess. The problem is the Sync/Async combination. You can't use OpenAsync and then Seek directly as it will not be opened yet. You can either use OpenCompleted event or synced Open. The problem after that is that you Seek is not synced and I don't provide Synched version of it or an event. It will work if you for example put a Thread.Sleep in between just to prove it works. However, I will need to provide a better way for that (it can be done with ShowFrame but just found an issue with it when used directly after open).
Buy me a beer when you come in Greece/Crete :)
from flyleaf.
@davsun55 With this commit now you can use this:-
Player.OpenAsync(@"c:\sample.avi");
Player.OpenCompleted += (o, e) =>
{
if (!e.Success)
return;
Player.ShowFrame(Player.VideoDecoder.GetFrameNumber(TimeSpan.FromSeconds(2).Ticks));
Player.TakeSnapshotToFile(@"c:\sample.jpg");
};
I will review also Seek/SeekAccurate if can use a synced version or an event
from flyleaf.
@davsun55 I've added SeekCompleted so now you can better use the following:-
Player.Config.Player.AutoPlay = false;
Player.OpenCompleted += (o, e) =>
{
if (!e.Success)
return;
Player.Seek(20_000);
};
Player.SeekCompleted += (o, e) =>
{
if (e == -1)
return;
Player.TakeSnapshotToFile(@"c:\sample.jpg");
};
Player.OpenAsync(@"c:\sample.avi");
from flyleaf.
Since I'm taking the snapshot to immediately show a thumbnail of the video before they press play, the .OpenCompleted doesn't work quickly enough. However this works:
flPlayer.Open(SampleVideo);
Thread.Sleep(500);
pbSnapshot.Image = flVideo.Player.TakeSnapshotToBitmap();
flPlayer.Stop();
But it would be good to have a solution that doesn't require the somewhat arbitrary thread.sleep.
We were in Greece in 2014 and loved it - especially the Moussaka on Rhodes! And we decided that Greeks make the best Turkish Delight.
:)
from flyleaf.
@davsun55 This should work if you set the Player.Config.Player.AutoPlay = false;
from flyleaf.
I can wait till your next NuGet release so you don't need to answer this, but how do I incorporate your Player.SeekCompleted changes right now? I've downloaded the current package with your changes, rebuilt it as 'release' and copied the resultant FlyleafLib.dll and FlyleafLib.xml over the top of the v3.7.42 package files. But Player.SeekCompleted is not present...
from flyleaf.
The easiest way would be just adding the FlyleafLib project to your solution and reference it instead of using the NuGet package. Alternative you can release (pack) a new version custom and add a local repository folder in your VS. I would have a version for your but I want to review it before release it (I think i will do few changes).
from flyleaf.
from flyleaf.
If understood correctly:-
flPlayer.Config.Player.AutoPlay = false;
flPlayer.OpenCompleted += (o, e) =>
{
if (!e.Success) return;
flPlayer.SeekCompleted -= FlPlayer_SeekCompleted;
flPlayer.SeekCompleted += FlPlayer_SeekCompleted;
flPlayer.SeekAccurate(2000);
};
flPlayer.OpenAsync(SampleVideo);
...
private void FlPlayer_SeekCompleted(object sender, int e)
{
flPlayer.SeekCompleted -= FlPlayer_SeekCompleted;
if (e == -1) return;
pbSnapshot.Image = flVideo.Player.TakeSnapshotToBitmap();
}
You could also check the e (int e) which is the ms that is 2000 (and not 0)
from flyleaf.
Related Issues (20)
- To get thumbnail of the video on seek bar HOT 1
- How to send commands directly to FFMPEG engine while video is loaded and playing HOT 3
- about key redefine~ HOT 2
- Audio render should be on different thread HOT 4
- Open/OpenAsync with ClearScreenOnOpen still shows black frame HOT 3
- I would like to print a specific part of the image by blurring it, is this possible? HOT 1
- About ShowFramePrev HOT 2
- Overlaps and Refresh in SharedOverlay
- Stream synchronization issue HOT 7
- Possible handle leak when repeatedly create/play/stop/dispose flyleaf players HOT 13
- Open stream at current position HOT 6
- FlyleafSharedOverlay in wpf ViewBox HOT 3
- Renderer: Level/Gamma Support HOT 4
- crash by set curtime HOT 2
- SharedOverlay as the Visual of a VisualBrush
- Get FlyleafSharedOverlay DetachedContent as Visual HOT 8
- Decoder (Subtitles): Bitmap Support HOT 1
- Issues of brightness control HOT 1
- [New feature requests]Added multi-threading support for M3U8 HOT 3
- Demuxer: Blu-Ray Support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flyleaf.