+ Reply to Thread
Results 1 to 2 of 2

Thread: Playing MP3 files

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    35

    Playing MP3 files

    I am trying to play MP3 files inside my application , but can't , application only run WAV files and not any other format.
    Last edited by davis; 11-08-2012 at 11:17 PM.

  2. #2
    Junior Member
    Join Date
    May 2012
    Posts
    27
    You will need to import that Namespace :
    Code:
    using System.Runtime.InteropServices;
    Insert these lines inside the Public partial class :
    Code:
    [DllImport("winmm.dll")]
    private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback);
    private string _command;
    Play MP3 function :
    Code:
    _command = "open \"" + reminder.SelectSingleNode("AlarmFileLocation").InnerText + "\" type mpegvideo alias MediaFile";
    mciSendString(_command, null, 0, IntPtr.Zero);
    _command = "play MediaFile";
    // that is for repeating
    //_command += " REPEAT"; 
    mciSendString(_command, null, 0, IntPtr.Zero);
    Stop the mp3 track from playing :
    Code:
               
    _command = "close MediaFile";
    mciSendString(_command, null, 0, IntPtr.Zero);
    I have tested that on my application and it works more than fine.

    Good luck.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts