When trying to set the URL in axWindowsMediaPlayer1 error: The Ссылка на объект не указывает на экземпляр объекта . The object itself really exists. The video player code is copied from another form, where everything works.
public partial class Video : Slide { public AxWMPLib.AxWindowsMediaPlayer axWindowsMediaPlayer1; public string bpath; public PictureBox video; public Video(string apath, string bpath) : base (apath) // apath - путь к фото из класса Slide, bpath - путь к видео { this.bpath = bpath; this.video = new System.Windows.Forms.PictureBox(); this.video.BackColor = System.Drawing.Color.Transparent; this.video.BackgroundImage = global::StPavel_TheForestSong.Properties.Resources.video2; this.video.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; this.video.Cursor = System.Windows.Forms.Cursors.Hand; this.video.Location = new System.Drawing.Point(387, 162); this.video.Name = "video"; this.video.Size = new System.Drawing.Size(70, 70); this.video.TabStop = false; this.video.Click += new System.EventHandler(video_Click); this.axWindowsMediaPlayer1 = new AxWMPLib.AxWindowsMediaPlayer(); this.axWindowsMediaPlayer1.Enabled = true; this.axWindowsMediaPlayer1.Location = new System.Drawing.Point(79, 12); this.axWindowsMediaPlayer1.Name = "axWindowsMediaPlayer1"; ComponentResourceManager resources = new ComponentResourceManager(typeof(Video)); this.axWindowsMediaPlayer1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axWindowsMediaPlayer1.OcxState"))); this.axWindowsMediaPlayer1.Size = new System.Drawing.Size(430, 280); this.Controls.Add(this.video); this.Controls.Add(this.axWindowsMediaPlayer1); } private void video_Click(object sender, EventArgs e) { oneSlide(0); this.axWindowsMediaPlayer1.Visible = true; } public override void oneSlide(int i) // показывает одно видео { axWindowsMediaPlayer1.URL = "G:\\mf.mp4"; } }
NullReferenceExceptioninstead of a message,Ссылка на объект не указывает на экземпляр объекта. - Vadim Ovchinnikov