How to control a Media Player with C#? - c#

I searched a little, but I have found a lot of old results, so I decided to ask here.
I want to control a Media Player playlist. I don't want to create a form with media controllers.
I want to open my media player and let a windows application control the playlist.
Based on a music list I want to do a few operations like play/pause/stop and insert a track in a specific position of the playlist. Is this possible?

Have you looked at the Windows Media Player SDK
There's a specific section for Playlists too.

Related

How to handle the Keyboard music shortcuts (play/pause/previous/next) in UWP?

I'm developing a Music player app for UWP which can play music in background.
Note that I'm using old 2 layer music app pattern one for foreground and one for background music.
In the app i want to handle the Keyboard music controls like Play, Pause, Next and Previous. can anyone help me out with proper way of implementing the keyboard music controls?
The keyboard shortcuts such as Play, Pauseand so on you mean here are actually the System Media Transport Controls(SMTC).
can anyone help me out with proper way of implementing the keyboard music controls?
Actually, starting with Windows 10, version 1607, UWP apps that use the MediaPlayer class to play media are automatically integrated with the SMTC by default. Simply instantiate a new instance of MediaPlayer and assign a MediaSource, MediaPlaybackItem, or MediaPlaybackList to the player's Source property and the user will see your app name in the SMTC and can play, pause, and move through your playback lists by using the SMTC controls.
This is the recommended way of interacting with the SMTC for most scenarios.Details please reference Integrate with the System Media Transport Controls. There are a few scenarios where you may need to implement manual control of the SMTC. For this please reference Manual control of the System Media Transport Controls.
but i need it to work even in background.
According to the remark section of SystemMediaTransportControls class:
The system transport control allows a user to control a music application that is in the background as well as get and set the current information on which track is playing.
So that SMTC should also work for music in background.
For a sample please reference the official sample.

Play a video on the default media player in Universal App

I would need to execute a function that plays a video in the default media player(Phone or Tab) from Universal Apps that uses Xaml and C#.
I don't want to embed the player .Actually my need is to open a new window with the default player and tell it to play the selected file.
All samples that I've saw in Google are to create an embedded player or send to a device Only.
Could you please give some suggestion for this issue. Thanks in Advance.

Play a video on the default media player from a Windows Store App?

I want to implement a function that plays a video in the default media player from a windows store apps that uses Xaml and C#.
I don't want to embed the player I want to open a new window with the default player and tell it to play the selected file.
All the samples that I've found are to create an embedded player or send to a device.
Can anybody help me?
Thanks...

How to use two controls for movie player?

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#)

How can I control an instance of Windows Media Player in c#?

I'm trying to control windows media player in c#. That means, I want to be able to programmically play songs. To reiterate, I'm talking about the full version of WMP, not the component you can embed into a windows form. I can launch the WMP process just fine, the problem comes in actually controlling it as I can't think of any keypresses I can send to the player that would tell it to select a song and play music. I can do this in iTunes just fine by sending a spacebar key-press to the process, but not so in Windows Media Player. Does anyone have any ideas as per how I can control widows media player programmically in C#? Is there a special command I can send to the process to complete this task?
Here is a link do how to interact with WMP using p/invoke...
This is a question that's almost identical to this one that has already been answered in Stack Overflow.

Categories