Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a class: Player.cs
Since I dont want the class to create a new axWindowsMedia object I have this constructor:
C#
public AxWMPLib.AxWindowsMediaPlayer player;
class Player
{
  public Player(AxWMPLib.AxWindowsMediaPlaye theObject)
  {
    this.player = mediaPlayer; //This is the error line
  }
}
The error occurs when I try to make a instance of the class:

C#
Player p = new Player(axWindowsMediaPlayer); //line 56
What do I have to do to use the property object declared in my class instead of creating a new one inside the class?
Posted
Updated 9-Mar-12 16:08pm
v3
Comments
Sergey Alexandrovich Kryukov 9-Mar-12 20:30pm    
Isn't it obvious that you did not provide full information? What is the exact compile-time type of 1) this.player? 2) axWindowsMediaPlayer? Wyat is the scope of declaration "public AxWMPLib.AxWindowsMediaPlayer player;"? Pay attention: it is not shown as a member of the class Player. Is it, really? Why did you show this line before the definition of the class Player?

Just a mess. The problem is simple: you need matching classes, identical or assignment-compatible.

Why not using System.Windows.Media.MediaPlayer (WPF)?

--SA
Sergey Alexandrovich Kryukov 9-Mar-12 20:32pm    
I don't believe the declaration "AxWMPLib.AxWindowsMediaPlaye theObject" is taken from your code. What do you type it manually, not copy-paste?
--SA
Ganesan Senthilvel 9-Mar-12 22:09pm    
share the complete code; no idea on mediaPlayer instance

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900