Preloading audio file with winmm.dll in C# - c#

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!

Related

Media Player seek option not working properly

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.

Find problems causing overload of program

I have a bot that plays a flash game automatically. I have loaded the flash object through an extended WebView a friend coded for me and I use native imports to send click messages to the handle. Everything works good for about 30 minutes. After that the bot, GUI and whole mechanism starts getting slower and slower, lagging more and more, eventually ending up clicking totally different coordinates. I suspect there's a memory leak or performance issue in my source code. How can I find that out or fix it?

Is it possible to get precise timestamps for frames in video file from VLC?

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

Reading specific frames from video file with .NET (not necessarily in sequential order)

I have a .NET Winform application and i need to show specific frames of a video file. Frames aren't necessarily in sequential order and are loaded when the user moves a slider, or when the application fires some events. I tried the following things:
Using EmguCV (OpenCV Wrapper): The problem here is that when i use SetCaptureProperty (With CAP_PROP.CV_CAP_PROP_POS_FRAMES, AVI_RATIO or MSEC ) to sets capture's position, the position isn't seted correctly (I checked it using GetCaptureProperty next to the SetCaptureProperty instruction). So, the frame returned by QueryFrame isn't the needed frame.
Using WPF MediaElement with Clock driven behavior: I can set the position of the video at the place that i need. The problem is that i don't know how get only one frame of the video sequence. By default, i have the Clock controller paused. When I set the position, If I call Clock.Controller.Resume(), then the video start playing from here. If I don't call Clock.Controller.Resume(), or if i call Clock.Controller.Resume() and then Clock.Controller.Pause() nothing is happening.
Im looking for another video library that can be used for accomplish this work, but i am not sure about what could be used. Any idea?
Thanks a lot for all comunity members, not only for help with this answer, but for the very big help that you give me with my problems every day. Iam new, but i would try to return these helping others with your problems.
Sorry for my terrible english! (Im spanish speaker and english speaking is not my best quality :S)

c# - wmplib - playing 2 mp3 files but can get them in synic

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.

Categories