Is there a way to access WMP10+'s playback speed controls in a dotnet app?
User level information on the Playback control information
Add the AxWMPLib to your VB/C# project.
Add an AxWindowsMediaPlayer control to your form.
Use the following method to access playback rate:
AxWindowsMediaPlayer1.URL = "e:\song.mp3"
AxWindowsMediaPlayer1.Ctlcontrols.play()
AxWindowsMediaPlayer1.settings.rate = 0.5
*Note that rate may not always be available depending on the media type. A safer method of accessing rate would look like:
If (player.settings.isAvailable("Rate")) Then
player.settings.rate = 0.5
End If
If that isn't what you're looking for, there also exists the MediaPlayer COM object. I didn't investigate it thoroughly, but intellisense yielded:
Dim mpMediaPlayer As New MediaPlayer.MediaPlayer
mpMediaPlayer.FileName = "e:\song.mp3"
mpMediaPlayer.Rate = 0.5
mpMediaPlayer.Play()
Hope that helps.
If you are using a MediaElement object, I would suggest adjusting the SpeedRatio property. Here is an example from Microsoft.
From your comment, it sounds like the SpeedRatio is the way to go. Because it allows you to adjust the playback speed. The MediaElement or MediaPlayer is basically just a Windows Media Player.
Related
I have a WPF application which dynamically loads video or image files(depending on user's choice, to a MediaElement control.
It is working fine when it is a video and gets the MediaEnded event fired on ending the video.
But when I load an image, the MediaEndedevent is fired within 5 seconds.
Is it a default value? or can I change it programmatically?
Is there any property to change this interval or disable such an option?
Is it possible to make it paused until a specific action?
I have set the following properties as follows
MediaControl1.LoadedBehavior = MediaState.Manual;
MediaControl1.UnloadedBehavior = MediaState.Manual;
MediaElement is a (very thin) wrapper around Windows Media Player (or rather - uses the same framework which is used by Windows Media Player). If you open an image in Windows Media Player - you will see it will "play" it like a slideshow (even for 1 image), for about 5 seconds. That's why you get MediaEnded event in 5 seconds - Windows Media Player plays slideshow with your image for that duration. I doubt there is a way to change this from WPF (because it's behavior of external program\framework, not related to MediaElement itself) and I'm not aware of the way to change this for Windows Media Player (and even if there is such a way - it will have global effect and you probably don't want to modify your clients computer in such a way).
To solve your problem - just don't use MediaElement for displaying images - use something like Image control. If you have really strong reasons to do that - you can pause MediaElement with Pause method after your "slideshow" has been loaded, then it will not fire MediaEnded event. All in all - I cannot imagine any use case where you really have to use MediaElement for images.
You can repeat the media when you load image. Handle MediaEnded event like this:
void me_MediaEnded(object sender, EventArgs e)
{
//play video again
mediaElement.Position = new TimeSpan(0, 0, 1);
mediaElement.Play();
}
Additionally see this. It may help:
https://stackoverflow.com/a/3406857/5675763
I want to play a video from the Internet in WPF. I used the code below. It can play the video but it always breaks down and the speed is very slow. I don't know how to solve this problem.
mediaElement.MediaFailed += mediaElement_MediaFailed;
mediaElement.LoadedBehavior = MediaState.Play;
mediaElement.Source = new Uri(#"http://media2.neu6.edu.cn/hls/cctv6hd.m3u8", UriKind.Absolute);
As I understand this is a long term issue with Media Element itself. Try using WPFMediaKit
instead.
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.
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:
Create a new WPF UserControl and add to your WindowsForms app.
In this UserControl add a media element and configure the way you want.
Build the solution.
Now in the toolbox must appear YourSolutionName Controls and you controls must be there.
Just drag it to your 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.
How can I use trackview or timeline in Naudio in C#?
Here is my code and it's not working.
I want to see my line going as track is playing.
NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(open.FileName));
customWaveViewer2.WaveStream = pcm;
stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
trackView1.NowTime = stream.CurrentTime;
Unfortunately, TrackView and TimeLine are not completed controls, and you would be better off writing your own custom control to place a vertical line at a position that represents the now playing time.
You would probably be best using a timer to invalidate your custom wave viewer, and in the Paint method, drawing a vertical line that represents the current play time.
I would like to send to another app current frame (number). Is it possible to access it in axWindowsMediaPlayer control?
I didn't see anything about this on axWindowsMediaPlayer control.
But you can use FrameGrabber project to extract frames from a movie.
FrameGrabber is an open-source library written in c# and it is easy to use.
Hope this helps.
This may be an old thread, but I feel like the question did not properly get answered. This may not be the "frame number" but it does give you a "position" of the video that you could pass. I am using it to sync two videos.
This is for a media player that has already been added to a VB form called AxWindowsMediaPlayer1. I am sure something similar can be called in C#
Dim position As Double
position = AxWindowsMediaPlayer1.Ctlcontrols.currentPosition