I am looking for a way to interact with a standalone full version of Windows Media Player.
Mostly I need to know the Path of the currently played track.
The iTunes SDK makes this really easy but unfortunately there really isn't any way to do it with Windows Media Player, at least not in .Net(C#) without any heavy use of pinvoke, which I am not really comfortable with.
Thanks
Just to clearify: I don't want to embedded a new instance of Windows Media Player in my app, but instead control/read the "real" full version of Windows Media Player, started seperatly by the user
Just add a reference to wmp.dll (\windows\system32\wmp.dll)
using WMPLib;
And then you can instantiate a media player
var Player = new WindowsMediaPlayer();
// Load a playlist or file and then get the title
var title = Player.controls.currentItem.name;
See Creating the Windows Media Player Control Programmatically for more information
For remoting the Windows Media Player, you can use the IWMPRemoteMediaServices interface to control the stand alone Windows Media Player. And you should be able to read all the informations you want like title or filename from your WMP player object. Unfortunately there is no C# smaple code in the SDK included. You can get the files from here: http://d.hatena.ne.jp/punidama/20080227 Look for the file WmpRemote.zip
Originally it's from here: http://blogs.msdn.com/ericgu/archive/2005/06/22/431783.aspx
Then you have to cast to the WindowsMediaPlayer object:
RemotedWindowsMediaPlayer rm = new RemotedWindowsMediaPlayer();
WMPLib.WindowsMediaPlayer myPlayer = this.GetOcx() as WMPLib.WindowsMediaPlayer;
and there you go..
I had this https://social.msdn.microsoft.com/Forums/vstudio/en-US/dbd43d7e-f3a6-4087-be06-df17e76b635d/windows-media-player-remoting-in-c?forum=clr in my bookmarks but have NOT tested it in anyway. Just a pointer in the right direction. It's nothing official and will require a bit of digging, but you should get a fairly simple wrapper (which will still use PInvoke under the hood - but you won't see it) around Windows Media Player.
Hope that helps.
Oh, I misunderstood. I thought you were talking about controlling the currently running Windows Media Player instance. If you are hosting Windows Media Player yourself then WMPLib is certainly the better solution.
The best info I have seen on interacting with Windows Media Player is this article written by Stephen Toub.
He lists a whole load of different ways to play dvr-ms files (doesn't really matter what format they are for this though). The bit that is possibly of interest to you is about using a Media Player ActiveX Control, which you can add to the visual Studio toolbox by right-clicking and adding the Windows Media Player ActiveX COM Control. You can then embed the player into your app, and access various properties of Media Player, like the url:
WMPplayer.URL = stringPathToFile;
This solution is possibly not what you want because it's starting a new instance of Media Player (as far as I know), however it might point you in the right direction.
Related
I have this Skin Programming Reference for Windows Media Player: https://learn.microsoft.com/en-us/windows/win32/wmp/skin-programming-reference
According to that reference BUTTON.image is the image attribute that specifies or retrieves the default image of the BUTTON, I wanna change the color or skin of a BUTTONELEMENT such as play, pause, stop, next, prev, etc., how do I set those properties through an AxWMPLib.AxWindowsMediaPlayer object? Is it even possible or does it need something else? I'd appreciate both C# or C++ examples.
Everything about skins is explained in the old WMP 9 SDK (Windows Media Player 9 Series Software Development Kit
There is a basic sample, RemoteSkin, which implements the IWMPRemoteMediaServices as explained at Using Skins with the Windows Media Player Control
Skins have the .wms or .wmz extension and are just zip files with all necessary files inside
You can find many examples of more advanced skins on the Web, like World Of Warcraft Skin for Windows Media Player (you can extract the files from WoW.wmz)
I'm writing an application that is intended to embed audio or preferably video in a windows form.
Right now I am using the standard MediaPlayer class (xWMPLib.AxWindowsMediaPlayer MediaPlayer) and am finding that it may not have some of the functionality that I am hoping for.
One of the features I would like to have in this application is 'unadulterated scrubbing' of said audio or video... Which in this context I would define as 'the ability to scrub the video without stopping playback' - or otherwise, continuing to play audio or video While scrubbing...
Examples of this can be seen in programs such as Adobe Premier; in which you can scrub the position of your video on the timeline, and at whatever rate you are scrubbing, it will play back some 'garbled' audio.
The intention in this feature is to grant someone the ability to ( using a foot pedal, in one instance ) roll back in the media and know exactly where they are, based on audio feedback...
This particular feature is very specific and debatable in its ability to be achieved, but the core of the question here is this; What would be your suggestions for a 'more fully featured' media player that can be utilized in a C# windows form?
Thanks in advance.
I have been struggling with an issue with my media player windows phone (7) application. The problem is that I can't seem to implement playlists.
What I want to do is play songs from the media library. This article seems pointless.
I've tried getting into the SongCollection class and figure out how to create more of these things. It appears to be impossible (no constructor, can't cast it, can't inherit it).
After that I tried getting an object on the process running the background audio agent that existed in my app (until I discovered it was redundant), and feed the media player one song at a time.
Problem is, I don't know when the media player stopped playing. It works ok as long as my app is in the foreground, but when it is not, everything stops working, only the media player keeps going.
Is there a way I haven't figured out? In the article above they suggest there is a link between the Zune Media Queue, which I presume is the MediaPlayer.Queue property, and various things I can implement, but I just can't figure a way to make it go.
You should give up since building your own media player is an impossible mission (been there, done that). You cannot create playlists or edit any information, you cannot replace default event handlers for on-screen music controls, you don't get events for music change in your application unless it is currently running.
Basically, it is really limited in what you can do right now and the situation isn't much better with WP8.
I hope that it will be less read-only by the time we get Windows Phone 9.
Take a look at the UWP samples from Microsoft:
https://github.com/Microsoft/Windows-universal-samples
The sample contains play/pause/playlists explanation.
This was already possible in Windows phone 7.5/8/8.1
Is there a media player, where you can control its audio and video using script or code.for example lets say i want to pause the video after n secs, which player supports this? I am looking for free opensource solution which runs on desktop i.e windows 7.
I'm not the kind of giving the entire solution. But here's a good place to start. It shows how to embed Windows Media Player in a Windows Form.
http://msdn.microsoft.com/en-us/library/bb383953(v=vs.90).aspx
You'll have access to control like play, stop, etc.
VideoLan supports such use.
For instance, see here: http://www.videolan.org/doc/play-howto/en/ch04.html
From the link:
--extraintf allows you to select extra interface modules that will be launched in addition to the main one. This is mainly useful for special control interfaces, like HTTP, RC (Remote Control), ... (see below)
The RC interface is probably best from a pure code/script point-of-view.
The HTTP interface is oriented towards a human using a webpage, but could be controlled from code, too.
I realize there is a similar question to this, but it really has no information in it. I want to retrieve the currently playing song title (similar to MSN Messenger) within a C# app. The Windows Media Player I want to control is EXTERNAL- that is, it is running on the computer, not within the app. Anyway to do this?
I think I may have found a way around my problem- a simple solution is to install a plugin that tells you the current playing song and writes it to a file and you can read it through your program.