Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. playing mp3 file using c#

playing mp3 file using c#

Scheduled Pinned Locked Moved C#
questioncsharphelplearning
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    achari ravi
    wrote on last edited by
    #1

    heloo can anyone please help me out in writing a code in c# for playing .mp3 files i tried a lot and found this as iam a beginner to c# i didn't understand what is this and how and where to place it ? [DllImport("winmm.dll")] private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback); thx.

    S A C 3 Replies Last reply
    0
    • A achari ravi

      heloo can anyone please help me out in writing a code in c# for playing .mp3 files i tried a lot and found this as iam a beginner to c# i didn't understand what is this and how and where to place it ? [DllImport("winmm.dll")] private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback); thx.

      S Offline
      S Offline
      Sathesh Sakthivel
      wrote on last edited by
      #2

      Don't Repost. I have answered Below.

      SSK. Anyone who says sunshine brings happiness has never danced in the rain.

      V 1 Reply Last reply
      0
      • A achari ravi

        heloo can anyone please help me out in writing a code in c# for playing .mp3 files i tried a lot and found this as iam a beginner to c# i didn't understand what is this and how and where to place it ? [DllImport("winmm.dll")] private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback); thx.

        A Offline
        A Offline
        achari ravi
        wrote on last edited by
        #3

        using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace audio1 { public partial class Form1 : Form { private string Pcommand; private bool isOpen; [DllImport("winmm.dll")] private static extern long mciSendString(string strCommand,StringBuilder strReturn,int iReturnLength, IntPtr hwndCallback); public void Close() { Pcommand = "close MediaFile"; mciSendString(Pcommand, null, 0, IntPtr.Zero); isOpen=false; } public void Open(string sFileName) { Pcommand = "open \"" + sFileName + "\" type mpegvideo alias MediaFile"; mciSendString(Pcommand, null, 0, IntPtr.Zero); isOpen = true; } public void Play(bool loop) { if(isOpen) { Pcommand = "play MediaFile"; if (loop) Pcommand += " REPEAT"; mciSendString(Pcommand, null, 0, IntPtr.Zero); } } public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { openFileDialog1.Filter = "|*.mp3"; openFileDialog1.ShowDialog(); textBox1.Text = openFileDialog1.FileName; Open(textBox1.Text); } private void button2_Click(object sender, EventArgs e) { Play(false); } private void button3_Click(object sender, EventArgs e) { Close(); } } }

        1 Reply Last reply
        0
        • A achari ravi

          heloo can anyone please help me out in writing a code in c# for playing .mp3 files i tried a lot and found this as iam a beginner to c# i didn't understand what is this and how and where to place it ? [DllImport("winmm.dll")] private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback); thx.

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          managed directX is much easier than this.

          Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          1 Reply Last reply
          0
          • S Sathesh Sakthivel

            Don't Repost. I have answered Below.

            SSK. Anyone who says sunshine brings happiness has never danced in the rain.

            V Offline
            V Offline
            Vasudevan Deepak Kumar
            wrote on last edited by
            #5

            You can actually just paste the permalink which should act like a 302 Redirect. :)

            Vasudevan Deepak Kumar Personal Homepage
            Tech Gossips
            A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups