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 files in c#

playing .mp3 files in c#

Scheduled Pinned Locked Moved C#
csharphelp
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

    can anyone please help me out in writing a code in c# for playing .mp3 files thx. in advance

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

      can anyone please help me out in writing a code in c# for playing .mp3 files thx. in advance

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

      You can use the windows media player control, or managed DirectX for 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
      • A achari ravi

        can anyone please help me out in writing a code in c# for playing .mp3 files thx. in advance

        G Offline
        G Offline
        Giorgi Dalakishvili
        wrote on last edited by
        #3

        Have a look at this: Playing mp3 file[^]

        #region signature my articles #endregion

        1 Reply Last reply
        0
        • A achari ravi

          can anyone please help me out in writing a code in c# for playing .mp3 files thx. in advance

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

          Get It.

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

          A 1 Reply Last reply
          0
          • S Sathesh Sakthivel

            Get It.

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

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

            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
            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