|
Hello
I wanna ask that what is the reason that I am not able to play the mp3 file.
my whole code for the "class" for simple audio player is as below:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace myplayer
{
class Player
{
[DllImport("winmm.dll")]
private static extern long mciSendString(string lpstrCommand, StringBuilder lpstrReturnString, int uReturnLength, int hwndCallback);
public void open(string file)
{
string command = "open\"" + file + "\" type mpegvideo alias MediaFile";
mciSendString(command, null, 0, 0);
}
public void play()
{
string command = "play MediaFile";
mciSendString(command, null, 0,0);
}
public void stop()
{
string command = "stop MediaFile";
mciSendString(command, null, 0, 0);
command = "close MediaFile";
mciSendString(command, null, 0, 0);
}
}
}
|
|
|
|
|
One obvious problem is that you don't have a space between open and the opening question mark of the file name in your open method.
|
|
|
|
|
please write your correct code here.
|
|
|
|
|
There's no need for that. What he described is spot on.
Look at the open command you're sending:
string command = "open\"" + file + "\" type mpegvideo alias MediaFile";
There is no space between the word "open" and the first quote mark where you sepcify the file name!
The result is your open command looks like this:
open"somefilename.mpg" type mpegvideo alias MediaFile
instead of this:
open "somefilename.mpg" type mpegvideo alias MediaFile
What do you think you have to do to fix that little problem??
|
|
|
|
|
hmmm Thank you so much Buddy.....
I am a beginner so i had face that problem
|
|
|
|
|
but it is still not workin.....I mean it is not playing............
What should I explain so that I can achieve more from you....
|
|
|
|
|
You're sending null in place of a buffer to hold any return information, so you're basically not getting any error information back from MCI.
You might also want to try removing the "type mpegvideo" from your command to see if that does anything.
|
|
|
|
|
You main problem is that you do not check the response from your mciSendString commands so you have no idea whether any of them have succeeded.
|
|
|
|