C# Music Player

Results 1 to 15 of 15
  1. #1
    Account Upgraded | Title Enabled! wichard is offline
    MemberRank
    Jul 2009 Join Date
    The NetherlandsLocation
    649Posts

    C# Music Player

    Hello guys, when i was making BrickEmulator i made this for teh Lulz.


    Example
    Code:
    MusicPlayer Player = new MusicPlayer("http://download790.mediafire.com/4rhxfimwc8ng/dc3crb5jma6m83k/Nyan+Cat+%5Boriginal%5D.mp3",true);
    MusicPlayer Class

    Code:
        class MusicPlayer
        {
            private readonly string Path;
            private string Command = string.Empty;
            private Boolean Loop = false;
            private Boolean Started = false;
    
            [DllImport("winmm.dll")]
            private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback);
    
            public MusicPlayer(string Path, Boolean Loop)
            {
                this.Path = Path;
                this.Loop = Loop;
    
                Command = "open \"" + Path + "\" type mpegvideo alias MediaFile";
    
                mciSendString(Command, null, 0, IntPtr.Zero);
            }
    
            public void Start()
            {
                if (!Started)
                {
                    Command = "play MediaFile";
    
                    if (Loop)
                    {
                        Command += " REPEAT";
                    }
    
                    mciSendString(Command, null, 0, IntPtr.Zero);
                    Started = true;
                }
            }
    
            public void Stop()
            {
                if (Started)
                {
                    Command = "close MediaFile";
                    mciSendString(Command, null, 0, IntPtr.Zero);
                    Started = false;
                }
            }
        }


  2. #2
    Valued Member TenShie is offline
    MemberRank
    Apr 2011 Join Date
    Frankfurt a. M.Location
    115Posts

    Re: C# Music Player

    wohoo u build one after the other Very Nice !

    You are very ambitious! *_*
    Last edited by TenShie; 08-08-11 at 12:14 PM.

  3. #3
    Account Upgraded | Title Enabled! jeroen262 is offline
    MemberRank
    Feb 2009 Join Date
    231Posts

    Re: C# Music Player

    Empty some private messages ^^
    I want to contact you, but can't.

  4. #4
    Account Upgraded | Title Enabled! George2000 is offline
    MemberRank
    Jul 2011 Join Date
    The NetherlandsLocation
    1,150Posts

    Re: C# Music Player

    And this is for?

  5. #5
    Account Upgraded | Title Enabled! TheNikolas is offline
    MemberRank
    Jul 2011 Join Date
    NorwayLocation
    216Posts

    Re: C# Music Player

    Very very nice. : ) Keep up the good work.

  6. #6
    Account Upgraded | Title Enabled! wichard is offline
    MemberRank
    Jul 2009 Join Date
    The NetherlandsLocation
    649Posts

    Re: C# Music Player

    Quote Originally Posted by George2000 View Post
    And this is for?
    Windows Forms, if you wanna play a Music File in you GUI. Use this.

    I tryed to play Nyan Music.. Wont work in Console App.

  7. #7
    Account Upgraded | Title Enabled! George2000 is offline
    MemberRank
    Jul 2011 Join Date
    The NetherlandsLocation
    1,150Posts

    Re: C# Music Player

    Quote Originally Posted by wichard View Post
    Windows Forms, if you wanna play a Music File in you GUI. Use this.

    I tryed to play Nyan Music.. Wont work in Console App.
    Seems to be nice, but won't use it because it will be annoying + I have youtube.

  8. #8
    Sydius is a Master Mudkip sidle is offline
    MemberRank
    Jun 2009 Join Date
    In the buttLocation
    301Posts

    Re: C# Music Player

    Quote Originally Posted by George2000 View Post
    Seems to be nice, but won't use it because it will be annoying + I have youtube.
    yeah, hmm i don't see the point why we would use this anywayz.

  9. #9
    Account Upgraded | Title Enabled! George2000 is offline
    MemberRank
    Jul 2011 Join Date
    The NetherlandsLocation
    1,150Posts

    Re: C# Music Player

    Quote Originally Posted by sidle View Post
    yeah, hmm i don't see the point why we would use this anywayz.
    People who are too lazy to go to youtube or if they go to youtube their browser will freeze.

  10. #10
    Account Upgraded | Title Enabled! TheNikolas is offline
    MemberRank
    Jul 2011 Join Date
    NorwayLocation
    216Posts

    Re: C# Music Player

    Quote Originally Posted by wichard View Post
    Windows Forms, if you wanna play a Music File in you GUI. Use this.

    I tryed to play Nyan Music.. Wont work in Console App.
    If there are going to be Nyan music in the console app running all the time, I think I'm gonna jump of a cliff.

  11. #11
    Developer Quackster is offline
    DeveloperRank
    Dec 2010 Join Date
    AustraliaLocation
    3,479Posts

    Re: C# Music Player

    This isn't Habbo related.

    ---------- Post added at 09:23 PM ---------- Previous post was at 09:22 PM ----------

    Should have released at Coders paradise :D

  12. #12
    What about no. Davidaap is offline
    MemberRank
    Nov 2009 Join Date
    773Posts

    Re: C# Music Player

    Quote Originally Posted by TheNikolas View Post
    If there are going to be Nyan music in the console app running all the time, I think I'm gonna jump of a cliff.
    HOW DARE YOU, NYAN CAT IS KING!

  13. #13
    Alpha Member Justei is offline
    MemberRank
    Oct 2007 Join Date
    /f241Location
    1,904Posts

    Re: C# Music Player

    Wont this pretty much only play wav files? :P (Seeing that you use the winmm lib)

  14. #14
    Valued Member unkn0wn32 is offline
    MemberRank
    Jul 2011 Join Date
    FloridaLocation
    124Posts

    Re: C# Music Player

    where i add "MusicPlayer Class"?!

  15. #15
    something Erlend is offline
    MemberRank
    Dec 2007 Join Date
    Oslo, NorwayLocation
    791Posts

    Re: C# Music Player

    @unkn0wn32

    Simply by adding a new class in c#, and entering the code.



Advertisement