I have 2 windowsMediaPlayer objects setup
Both objects have the same mp3 song file but when I play them at the same time they are out of sync by a few seconds. The code I call to play them looks like this
sound1.controls.play();
sound2.controls.play();
Is it just because one play method is executed before the other and thus one fast then the other. Is their anyway I could sync them? I have tired messing with the rate of one track to match the other, but not getting it prefect.
Thanks
You can't get this perfect, the players cannot start at the same time by design. You'll need to mix the two songs into a new song, the NAudio library can do this.
Related
I am writing a wave audio player using C# and winmm.dll. To reduce the delay while switching from one file to the next, I open the next file with a different alias. While switching to the next file, I stop the first alias, and then play the second one.
Everything works great, until the user waits a while (i.e. 20 minutes) before playing the next (preloaded) file. In this situation the player has a 5 seconds delay before playing the new file, which has been preloaded for a while.
The question is, does winmm.dll put not-used-files in a "standby" mode? Do we need to activate it in certain time periods to reduce the delay? If yes how to do that?
I found a status called "parked" but this is never returned, and I can't find anything on the web describing it.
It would be a great help, if someone could help, cause there is not much documentation out there for this DLL.
MCI Commands
Thanks in advance!
Hello fellow developers.
I made a c# player to play videos and audio. To do that I used the System.Windows.Media MediaPlayer and it works great.
Here is the problem I encountered:
In some music files (not all of them) seeking to X time or playing it from the beginning to X time will have diffrent results.
In other words, If I play the song from the beginning, after 20 seconds the singer will say "Hello" but if I use the seek function to 20 sec I will hear the singer say something else (and 2 seconds later he will say "Hello").
I had to check if its the library mistake so I opened windows media player and played the song, When I click on the progress bar to X progress or when I play from the beginning to X progress the song is at different time.
Same like the library.
I checked this with VLC and it worked perfectly.
So here is my questions to you.
Does it mean that Media Player doesn't know how to seek this music file correctly?
Do you know how to fix this?
Should I use a different player, which one do you recommend?
I found the problem,
Encoding the audio as VBR made it happen like that.
Changing to CBR solved this.
I want to record sound to a file and at the same time I want to be able to play audio from the same file in C#
For example, play the last 15 seconds but the microphone has to keep on registering and recording while replaying.
Is this possible and in that case, which is the best approach to do this?
The answer is YES, and you should play around with low level audio API, namely WaveIn/Out functions from winmm.dll, through P/Invoke in C#.
In short words, you need to use WaveIn to capture input signal from a input device and store in some structure, then use WaveOut to play back the audio simultaneously, or some delay after.
Here is a project you can start with: a duplex audio player. You can download the project and play around with it and see how it achieves it, then do some modifications upon the project to achieve what you want :)
I’m looking to use VLC as the foundation for a video player within my application written in C# (since VLC is one of the few players that can properly decode the format I’m working with), but the primary tasks that I need it to perform are:
Ability to browse between separate frames in a video file, both
forward and back.
Displaying a precise timestamp for each frame down to the
millisecond, and the ability to relay the timestamp to an
application.
Right now I’m doing this by means of a VLC extension LUA script, but the time VLC returns via vlc.var.get(input, “time”) lacks precision and can differ for the same frame in the same video file across multiple file readings. The frame browsing doesn’t work too reliably either. Plus, the values received in this way cannot be automatically relayed to another application.
I tried using the LibVLC.NET wrapper for libVLC, but I still couldn’t browse between frames, and the millisecond count values returned were rather odd. It’s almost like VLC (libVLC) doesn’t return an actual time value during playback but rather some sort of rounded value, a value with substantial delay when reading with precision down to the millisecond. The standard VLC interface can neither display precise time values down to the millisecond, nor browse between frames.
Is there any viable way to perform the two aforementioned tasks with VLC by somehow running VLC from an application written with the use of .NET? Or should I look into other options?
I am not sure that you can do that with VLC. But you can use this example which uses very good framework called ffmpeg
I am almost sure that you will be able to play your stream and navigate through. In addition there is another solution that you may use , I have to say that i am not familiar with it but it worth checking.
Basically try to find .Net implementation of video player instead of working VLC
I want to be able to precisely control the timing of .wav files played in my program. I also want to be able to play more than one .wav file at the same time. The SoundPlayer was not good enough because I can't play two sounds at once, and even when I play different sounds consecutively, there is about a 1/8th second delay between each sound, which is unacceptable for what I am doing. I cannot find a way to add a Device using SharpDX.
You have a directsound sample in sharpdx, should get you started.
Also you can have a look at NAudio , which should also fit your needs and be a bit easier to use.