Reputation: 17164
I'm using the Video Source Player control from AForge.Controls
to play a few video clips within a winforms application.
The code is something like this.
string fileName = @"C:\path\to\file.example";
videoSourcePlayer.VideoSource = new AForge.Video.AsyncVideoSource(new FileVideoSource(fileName), true);
videoSourcePlayer.Start();
The video file includes both audio and video streams, however as far I'm aware the control only handles video and not audio.
How can I then play the audio stream in a synchronous fashion with the video source player control?
Thank you.
EDIT:
The Video Source Player control
has a event named NewFrame
, which allows to determine the precise video position which could be useful to keep the audio being played synchronized with the video.
Upvotes: 2
Views: 1304
Reputation: 3976
Since you mentioned:
I'm only looking for other alternative in which is possible to reproduce the audio contained the video file and somehow keep it synchronized with the video player control...
Maybe you can have a better luck by using a ElementHost
and using WPF media control.
If this solution is eligible for you follow this steps:
UserControl
and add to your WindowsForms
app.UserControl
add a media element and configure the way you want.YourSolutionName Controls
and you controls must be there.WindowsForms
app and it must create an ElementHost
.I've created the UserControl
as follow:
<MediaElement Name="VideoMediaElement"
Source="Media/Wildlife.wmv"
LoadedBehavior="Manual"/>
Just remember in this example this file must be side-by-side with your app in a Media
folder. If you miss this step it will give you the strange and not helpful error 0xC00D11B1
.
The loaded behavior Manual
will give you the chance to control de video more freely.
After that you can do whathever you want in this UserControl
like create Play
and Pause
:
internal void Play()
{
this.VideoMediaElement.Play();
}
And to access them in WindowsForms
do this:
private void WindowsFormsButton_Click(object sender, EventArgs e)
{
var videoControl = this.MyElementHost.Child as VideoUserControl;
videoControl.Pause();
}
Hope this helps. WPF MediaElement is much more easy to seach for than other libs.
Upvotes: 2