Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I am creating a WPF media player using MediaElement class in WPF. Here i can play the local videos (Available in my PC) but i cannot play an online video. Can anybody knows what i have to do for this?
Please help me anybody.
Thanks,
It looks like you can totally do that. However, you may running into issues with the type of video you're trying to play (file type), an authentication issue with the site you're trying to stream videos from (i.e. you need to be logged in), or the URL is malformed/incorrect. One way to test that is to hook up the MediaFailed event handler and pop up a message whenever that's raised so you can get some insight into what's going on.
I was able to wire this up in a few minutes. The H.264 videos worked fine for me.
public MainWindow()
{
InitializeComponent();
MyMediaElement.MediaFailed += MyMediaElement_MediaFailed;
MyMediaElement.LoadedBehavior = MediaState.Play;
MyMediaElement.Source =
new Uri(#"http://somesite/somevideo.mp4", UriKind.Absolute);
}
void MyMediaElement_MediaFailed(object sender, ExceptionRoutedEventArgs e)
{
MessageBox.Show(e.ErrorException.Message);
}
As WPF mediaelement internally uses windows media player. If you alter the buffer settings of media player from default buffer setting to custom. Open windows media player Tools Options Performance. As highlighted in the image below.
When you choose “Buffer” option and set “Seconds of content” to 2. The following registry values will be added under media player.
HKEY_CURRENT_USER\Software\Microsoft\MediaPlayer\Preferences
UseDefaultBufferTime=0
CustomBufferTime=2000
You can use dotnet registry class to make changes.
Refer this link:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/1b4b8fb9-ff8f-4861-8e99-4a7a4fc75596/setting-windows-media-player-properties-in-wpf?forum=wpf#ac879a7f-37bc-4ccc-854d-ab6e047086e5
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I need help to make my program. I have developed a form in C# that only has a textbox and a button to take a photo using the webcam and save it in the file path specified.
So I need a method to start the webcam, take a photo and save it in the file path and close the webcam immediately. No need to see what the webcam shows, just take the photo very fast and save it.
Any idea how I can do that? All comments are welcome. Thanks in advance.
Windows APIs to access a webcam are native, but you can use well known wrappers:
First, DirectShow.NET's DxSnap sample
Use DirectShow to take snapshots from the Still pin of a capture
device. Note the MS encourages you to use WIA for this, but if
you want to do in with DirectShow and C#, here's how.
Related on StackOverflow:
Photo and video with webcam using DirectShowLib-2005
Capturing frames from webcam using DirectShow.NET
DirectShowLib - Can't take more than one picture with webcam. Got "Insufficient system resources exist to complete the requested service" error
DirectShow Library-How to capture image using directshow library without showing the webcam live images on the PictureBox or Panel
Capturing a photo on x86 Atom Windows 8, DirectShow
Second, Media Foundation.NET which wraps Media Foundation API
See How to grab constant stream of bitmap images from webcam in c# for related references
Then, other libraries, that eventually wrap mentioned above APIs (including referenced by links above)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I need a digital typeing sound effect.when numbers are typed,Sound effect appears in background of the video.I want to make a program that when I press the keyboard, I also listen this sound effect.How can I find this sound effect or take from this video?
the sound effect between 0:50 and 1:15
www.youtube.com/embed/kIXNpePYzZU
For the 'extracting the sound effect' part of the question, you would likely want to use an online video/audio downloader/converter. In the past, I have used youtube-mp3.org and clipconverter.cc.
For the second part of the question, it depends what exactly you want. If you want it to apply only to a specific text box in a WinForms/WPF/UWP app you are writing, this should be reasonably easy. The exact method depends on what you are doing, but involves adding a keydown, keyup, or keypress event handler to the text box
If you want it system wide, this is more difficult. Searching for 'Global Keyboard Hook C#' appears to give good results.
Once you have detected the key press, have a look at this question for how to play the sound. The answer by bporter gives the following code:
System.Media.SoundPlayer player = new System.Media.SoundPlayer(#"c:\mywavfile.wav");
player.Play();
Use this to convert the video to mp3. Clip the sound effect out of the mp3. Then play the mp3 file with your code.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to record video and audio, from the user's system using asp.net and save on the server.
Is there any simple solution?
I see this link Code to record from webcam or default video and audio devices in asp.net? but this is for Video Recording , i need just voice recording.
To record sound from a microphone in a web browser you need to use the getUserMedia() JavaScript API. However, this is a somewhat new API that still might change and as far as I know there is no support for this in Internet Explorer and Safari today.
Another option is to use a plugin. Both Silverlight and Flash will allow you to record sound from a microphone but this constrains you to another set of browsers.
Even if you combine both solutions, e.g. use getUserMedia() in Chrome, Firefox and Opera and Silverlight in desktop Internet Explorer and Safari you will not be able to record sound on an iPad with Safari.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
How to detect if any video is being played now using autohotkey, autoit, vbscript, c#, or c?
Video could be being played/streamed in any local player, web based player, or html5 player. We do not know the name of player also player may not be in the full screen.
PS. Detecting CPU load may not give the correct result always, so it is not acceptable.
I've done a small bit of work on this back in the day. There is a WIN32API (old school) that gets/sets whether or not to disable the screensaver (in user32.dll, GetScreenSaverActive(), SetScreenSaverActive - see: http://www.codeproject.com/Articles/17067/Controlling-The-Screen-Saver-With-C). This is the most likely flag to be set when a video is playing but it not 100% reliable as not every player will implement it. It WILL work for most browser videos, whether played through plugin, natively, or via DirectX. This also works for most (all?) external players such as vlc, windvd, etc.
But.
There is no sure-fire, 100% way of determining a video playing. You cannot;
1. Check for sound playing as the user may be using iTunes and not all videos have sound
2. Check for full screen (usually the better option) as the video may be playing in a browser
3. Check cpu/gpu load as it's not reliable and you have no other way to determine
4. Be absolutely sure that the player hasn't cleared/reset the win32 flag when minimized
Another option would be to try and collate a list of possile executable names for all known players (doable but time consuming to find data, espesially on older versions), and check to see if they're running. This isn't 100% reliable either as a plugin by be preloaded but a browser but not actually playing a video at that moment in time.
In short, there's no 100% way that I know of but several ways that'll get you 90-95% there. That is the purpose of knowing if there's a video playing? Perhaps there's an easier way to find what you're looking for...
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I have an WPF application that starts a live tv recording using Windows Media Center, using the Windows Media Center SDK, waits 2 minutes and then plays the currently recording file (.wtv) in a WPF MediaElement. The problem is that the video visual will freeze and it is not consistent on when it happens. I have looked into it and discovered that the timeline is still moving so the MediaElement still thinks that the video is playing.
This happens only when trying to play a video file that is currently being recorded, previously recorded shows play just fine. Both Media Center and Media Player can play those files without any hiccups; it is only the WPF MediaElement that has this problem. Any help would be appreciated.
My guess is that the way the media element works is that it grabs the size of the file it's about to stream at the time you first play it and gets stuck after that. It's just a guess but I have no other information to go off of.
I do know that the MediaElement is really good at switching streams and resuming in those streams. Perhaps there is a work around you can find where every so often it will refresh the stream and resume from it's current position.
This sounds like an MS bug.
You could possible set up an HTTP proxy for the wtv file, then tell the MediaElement to play the stream and not give it the actual size. Its a lot of work but may just work.