Click here to Skip to main content
15,910,980 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hay there guys
I have a little trouble in my music player, see I had all the necessary code to make the player shuffle, loop etc.

But my player form looked very messy with all that tons of code, so I decided to condense all that code in a class called "Player", to me just to instantiate.

Now here is the dilema, since I have a axWMP1 object with a GUI interface in my form I wouldnt like to instantiate a new in my Player class so I made a constructor that requests a [AxWMPLib.AxWindowsMediaPlayer] object and just use it with all the complex and large methods I wrote.

AxWMPLib.AxWindowsMediaPlayer player;

public Player(AxWMPLib.AxWindowsMediaPlayer mediaPlayer)
{
this.player = mediaPlayer;
}

I have that code but it has a syntax error I dont know how to correct.
it happens when I instantiate the object:

Player mediaPlayer = new Player(axWMP1);

What´s the correct whay of doing this?

NOTE: I cant create a new object inside my class because the object in the form contains the GUI interface I need to display videos as well.

Thanks!
Posted
Comments
Sergey Alexandrovich Kryukov 26-Feb-12 20:16pm    
For goodness sake, what's the error? What's the problem? What's the code with the error? In what line?

How can you expect help if your question is that messy? You task here is simple: code sample -- exact error report with the line(s) in source code -- some explanation -- answer.
--SA
Member 8437747 28-Feb-12 19:14pm    
Its simple my friend:

I have a class: Player.cs
Since I dont want the class to create a new axWindowsMedia object I have this constructor:

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:

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?

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