0

I have a simple form that should start an mp4 soundless video in fullscreen, unfortunately I haven't be able to do that. My form consists of an axWindowsMediaPlayer control and a button when clicked video plays in full screen, I just needed that when I start the form the video starts in full screen without need to click the button. Thank you for some hints.

This is my code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AxWMPLib;
using WMPLib;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;
namespace Ethen
{
 public partial class FrmAzkar : Form
 {
 private int Tiks;
 public FrmAzkar()
 {
 InitializeComponent();
 axWindowsMediaPlayer1.uiMode = "none"; 
 TmrAzkar.Start();
 }
 private void FrmAzkar_Load(object sender, EventArgs e)
 {
 string path_to_video_file = "C:\\Mawakit-Al-Salat\\azkarFajr.mp4";
 if (File.Exists(path_to_video_file))
 {
 axWindowsMediaPlayer1.URL = path_to_video_file;
 axWindowsMediaPlayer1.Ctlcontrols.play();
 }
 else
 {
 MessageBox.Show("File not Found");
 }
 }
 private void TmrAzkar_Tick(object sender, EventArgs e)
 {
 Tiks++;
 this.Text = Tiks.ToString();
 if (Tiks == 540)
 {
 this.Text = "Done";
 TmrAzkar.Stop();
 this.Close();
 }
 }
 private void button1_Click(object sender, EventArgs e)
 {
 if (axWindowsMediaPlayer1.playState == WMPPlayState.wmppsPlaying)
 {
 axWindowsMediaPlayer1.fullScreen = true;
 }
 }
 }
}
marc_s
760k186 gold badges1.4k silver badges1.5k bronze badges
asked Dec 4, 2024 at 18:05
7
  • 1
    Try putting your axWindowsMediaPlayer1.fullScreen = true; code into the Shown() event of the Form? Commented Dec 5, 2024 at 15:23
  • Or you could attempt to make it fullscreen Commented Dec 5, 2024 at 15:25
  • I tried adding into form_load axWindowsMediaPlayer1.FullScreen = true; but always giving error: System.Runtime.InteropServices.COMException HResult=0x8000FFFF Commented Dec 5, 2024 at 17:02
  • Well, the Load() event occurs BEFORE the form (and the player) have been displayed. This is why I suggested the Shown() event of the form, which occurs AFTER the form has been displayed. This should guarantee that the player control has already been created. Commented Dec 5, 2024 at 17:24
  • sound logic but could not figure out how to use the Shown, any hint? Commented Dec 5, 2024 at 17:32

1 Answer 1

0

I had to do it from the StatusChange() event of the Media Player control.

Select the Media Player control (axWindowsMediaPlayer1), then switch to the events for it in the properties pane. Find the "StatusChange" event and double click it.

Now switch to fullscreen mode from there:

private void axWindowsMediaPlayer1_StatusChange(object sender, EventArgs e)
{
 if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsPlaying)
 {
 axWindowsMediaPlayer1.fullScreen = true;
 }
}

This worked for me in a bare bones UI with a video URL set in the Load() event of the form.

answered Dec 5, 2024 at 23:33
Sign up to request clarification or add additional context in comments.

1 Comment

Worked as expected, I must thank you alot, I have been stragling with this issue for a week. Thank very much.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.