Dear All,
I have one windows application where I want to play audio/videos files.
First of all, I have added the reference to the WindowsMediaPlay in Com tab in my project solution. I have then added this as the tool by right-clicking in the menu tool and selected the WindowsMediaPlayer.
What I have tried:
I have tried this code to run audio/videos files.
using AxWMPLib;
if (QuestionContext.Image != null)
{
string fileExtension = Path.GetExtension(QuestionContext.Image.TempLocalPath);
List<string> imageFileExtensions = new List<string>() { ".png", ".jpg", ".jpeg", ".bmp", ".gif" };
List<string> audioFileExtensions = new List<string>() { ".mp3", ".ogg", ".wav", ".wma" };
List<string> vedioFileExtensions = new List<string>() { ".mp4", ".wmv", ".mpeg", ".avi", ".mp3", ".ogg", ".wav", ".wma" };
if (imageFileExtensions.Contains(fileExtension))
{
PictureBox pictureBoxQuestionImage = new PictureBox();
pictureBoxQuestionImage.SizeMode = PictureBoxSizeMode.Zoom;
pictureBoxQuestionImage.Dock = DockStyle.Fill;
pictureBoxQuestionImage.Load(QuestionContext.Image.TempLocalPath);
PanelMedia.Controls.Add(pictureBoxQuestionImage);
}
else if (vedioFileExtensions.Contains(fileExtension))
{
AxWindowsMediaPlayer mediaPlayer = new AxWindowsMediaPlayer();
((System.ComponentModel.ISupportInitialize)(mediaPlayer)).BeginInit();
mediaPlayer.CreateControl();
mediaPlayer.enableContextMenu = true;
mediaPlayer.Name = "mediaPlayer";
mediaPlayer.Enabled = true;
mediaPlayer.URL = QuestionContext.Image.TempLocalPath;
mediaPlayer.settings.setMode("loop", true);
PanelMedia.Controls.Add(mediaPlayer);
mediaPlayer.Dock = DockStyle.Fill;
((System.ComponentModel.ISupportInitialize)(mediaPlayer)).EndInit();
mediaPlayer.uiMode = "full";
mediaPlayer.Ctlcontrols.play();
}
Click here to see the output of my code
When I run my application, the WindowsMediaPlayer running only audio and not displaying the video, even though the file is a video file.
Can anyone please help me to resolve this.
Thanks