I have created a movie player. I'm using the default windows control for Media Player. However I just saw that some movies do not work under it(some FLV files). However those files do work under Media Player Classic. So I was thinking about using the Media Player Classic control.
However
I want this movie player to be as portable as possible. So what I would like to do is to use Media Player Classic control when its available in system, but if its NOT than use Media Player control.
Is that even possible or do I need to create two applications that share the same code?
I would recommend using libvlc. VLC is really good about playing almost anything you give it. It is a C API but one could possibly DllImport their way to success and write code in C#.
Here are some good resources to get you started:
http://wiki.videolan.org/Libvlc
http://www.helyar.net/2009/libvlc-media-player-in-c/ (Shows how to DllImport and call the C code from C#)
Related
I'd like to be able to press a button to play a sound of a button being pressed while music is already playing. SoundPlayer is no help because it stops the music to play the sound.
I have added the sounds to my Resources (WindowsFormsApplication2.Resources.Properties.button) and I don't want to have to type in the file location.
Answer from MerickOWA
You CANNOT play two sounds at once using SoundPlayer.
SoundPlayer is using the native WINAPI PlaySound function to accomplish the task which has no support for playing simultaneous sounds. Creating multiple instances of SoundPlayer won't help.
There are many options most of which involve implementing a lot of the low level API to window's native audio library or DirectSound (note neither are C# and require alot of interop code)
The simplest option would be to depend on windows media player to play the audio for you.
Add a reference to "C:\Windows\System32\wmp.dll"
then use
var player = new WMPLib.WindowsMediaPlayer();
player.URL = #"..\..\bin\debug\tribal dance.wav";
Note: play starts immediately after setting the URL property
The down side of this approach is your reliance on media player for your application to work properly. On the upside, you can use any file format media player supports.
Lately, I've been trying to setup a media center PC. I've played around with all the common media center applications like XBMC, Plex, Boxee, and WMC. But all of them have one issue or another. So I was thinking about writing my own application from scratch.
My problem is I have no experience with developing software that plays media such as videos or music. I'm also not interested in spending a huge amount of time trying to figure this out, considering all the different file formats and codecs out there. I'm really more interested in developing the database and library interface for my application and reusing someone else's control or code for actually playing the media.
One option I was thinking was to just control an existing media player externally. So for example you may browse for a video to play in my application, and then when you hit play it would fire up VideoLAN or some other popular video player.
However, I was wondering if there was an easy way to play video inside a .NET application. I'm looking for something that is capable of playing a wide variety of formats such as MKV files, and DVD ISOs. I'm more experience with WinForms, but was also thinking about using this project as an opportunity to learn WPF.
i've spent many years looking at playing video under wpf.
The short answer
There is no easy way to guarantee to be able to play a variety of formats under wpf ( mkv,dvd etc etc ) or under windows for that matter.
the long answer
If you are looking just to run this at home and not release it, install all the codecs you need and most of the formats will run via mediaelement in wpf.
Getting all the codecs to cooperate can sometimes be frustrating.
Now moving into slightly harder territory.
if you want to play DVD then you need to replace mediaelement with wpfmediakit
http://wpfmediakit.codeplex.com/
wpfmediakit gives a base library to get access to the low level directshow functionality.
There is already a code base for playing DVDs based on wpfmediakit.
Now moving onto the very hard territory.
if you want to distribute your application and have users be able to "just watch" most/all media formats means you need to be able to completely control their codecs, which generally means distributing the codecs with your package and building the directshow filter graph in code rather than let windows build it.
The easiest way is to use the existing .Net hooks to Microsoft's standard MediaPlayer:
http://msdn.microsoft.com/en-us/library/system.windows.media.mediaplayer.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/dd562851%28v=vs.85%29.aspx
was trying myself a while ago for something to play media in winforms, and found out there is vlc wrappers for .Net, dunno how good they are as i gave up, but you can try
here is one them:
http://vlcdotnet.codeplex.com/
Thanks for all the great answers. But just found out that VLC can actually be controlled through HTTP. So I think I'm just going to use that to point an instance of VLC running with the HTTP interface at whatever file I want to play.
I am currently making a software that can be used to playback training packages. The features I want to add are:
Ability to read the time of videos
Ability to play and pause videos of various codecs (as bundled in Klite Codec Pack)
Ability to create a custom playlist file and continue from the last stop/pause of the playlist when opened
Generate a report of how the playlist was completed
I know very well how I am going to handle the last two parts but I need help on the first two. The current one simply has to launch the files using an external player on the system, and monitor the launched process for exit... but this is not quite what I want.
If WPF is an option you can use the <MediaElement/> for hosting the video in an application. Specifically you can use the Position property for getting and setting the current time.
As the <MediaElement/> is a wrapper for Windows Media Player, all videos playable in WMP should be playable in the <MediaElement/> (after you installed necessary codecs).
You can use VLC with the .Net Interface to VLC. It supports lots of codecs out of the box and seems to be really easy to use.
What is a sound library I can use to easily manipulate sound files (mp3, ogg, wav, etc.).
I'm doing this as a leasure project and as such I'm more than willing to read a bit because I want this to be a little learning experience.
Any help, SO? :D
If you need more than just .wav files, as it appears you do, and you're using .NET 3.0 or higher, have a look at:
MediaPlayer Class
It's basically a wrapper around Windows Media Player, and will let you do in code most (if not all) of what WMP can do.
If you're still in .NET 2.0, have a look at the Windows Media Player SDK, which is a significantly uglier wrapper around Windows Media Player. See this answer.
SoundPlayer class for wav. At the bottom of that documentation there is a link to a page explaining how to also play mp3 and wma.
I need to synchronize Windows Media Player with my application. I want to show the current song that WMP is playing in a ListBox in real time, with updates when WMP changes songs. How can I implement this?
A bit of sniffing around in Google gave me this: http://brandon.fuller.name/archives/hacks/nowplaying/wmp/, it looks like you need to write a plugin for WMP that exposes the information to your application. Depending on what you need/cost, the Plugin on that page might do the job!
Poll HKEY_CURRENT_USER\SOFTWARE\Microsoft\MediaPlayer\Player\RecentFileList\File perhaps.
We've controlled Windows Media Player through the Windows Media library (wmp.dll) and .NET Remoting, using a singleton service.
Look here:
How to interact with Windows Media Player in C#