sebapi

Audio Player on Smartphone using C#

12 posts in this topic

I have some problem.

I can create application in Windows Application. I add a media player control from toolbox. I can create this application too without add media player control from toolbox, just add right library (WMPLib wmp.dll) and everything work.

I have question: in what way can I create some kind of mp3 player on Smartphone using C# ? On deviceApplication project I can't find media player control in toolBox, so I add WMPLib library into project, but when I start my application, there is no sound.

I've noticed that, when I go to bin/debug directory and execute the exe file the application works and there is sound.

Can anyone help me ?

Thanks.

Sebastian

Edited by sebapi
0

Share this post


Link to post
Share on other sites

What version of .NET CF are you using?

What is the device?

you cannot add a WMP SDK control on the mobile application as the SDK is for PC's

you can however play sound through WMP as I had demonstrated/explained in this thread:

[will post link to thread]

but generally you need to import the System.Diagnostics name space

Make a process and run Windows media player given it the path to the audio file you wish to play as an argument

so could be something like:

Process audioPlayer = new Process();

audioPlayer.StartInfo = new ProcessStartInfo("wmplayer", "pathToFile");

audioPlayer.Start();

this code is for .NET CF 2.0

0

Share this post


Link to post
Share on other sites

I using .NET CF 2.0

I testing this application on default emulator for smartphone (.NET 2005)

I'll check your solution.

Thx

0

Share this post


Link to post
Share on other sites

I've checked this solution:

Process audioPlayer = new Process();

audioPlayer.StartInfo = new ProcessStartInfo("wmplayer", "Baby.mp3");

audioPlayer.Start();

When I use mp3 file then it appears message like:

"Cannot play the file. The file is either corrupted or the Player does not support the format you are trying to play".

If I use wav file then it appears message like:

"Cannot play the file because the specified network protocol is not supported. If you entered a URL to play the file, try a different protocol (such as HTTP). If you clicked a link to play the file, the link might not be valid"

Hmm...

Do enyone have some idea ?

0

Share this post


Link to post
Share on other sites

Have you provided the full path to the file?

0

Share this post


Link to post
Share on other sites
Have you provided the full path to the file?

<{POST_SNAPBACK}>

Yes, I have tried with full path. Maybe I give a wrong path ? Where should be mp3 file physically ? Could you give me some example ? Maybe I have to set some settings in emulator ?

0

Share this post


Link to post
Share on other sites

\ << this is the root directory of the phone in general

so if your mp3 was stored in my documents on the phone memory, path would be:

\My Documents\baby.mp3

in .NET 2.0 I believe, perhaps not for CF I cannot remember, there is a special path class/special folder class which allows you to select a folder of a special system type (like Windows, or my documents) - see if you can find it (I think its in the environment class) and use that to guide the path to the mp3 file.

if you store the mp3 file on storage card, path:

\Storage Card\someFile.mp3

0

Share this post


Link to post
Share on other sites
Process audioPlayer = new Process();

audioPlayer.StartInfo = new ProcessStartInfo("wmplayer", "Baby.mp3");

audioPlayer.Start();

Is there anyway to determine when the media clip has finished from within the C# code though? So that the player can be exited etc..

Cheers,

Steve

0

Share this post


Link to post
Share on other sites

unfortunately not, that is only possible I believe in Windows and the WMP SDK, not on Windows Mobile

0

Share this post


Link to post
Share on other sites
unfortunately not, that is only possible I believe in Windows and the WMP SDK, not on Windows Mobile

I tried to play mp3 file with the following code but it throws an error: "An object or name was not found" and when I try to play mp3 file I get the following error: "Cannot play the file. The file is either corrupted or the player does not support the format you are trying to play"

Process audioPlayer = new Process();

audioPlayer.StartInfo = new ProcessStartInfo("wmplayer", currentSoundTrack);

audioPlayer.Start();

Any idea??

Thanks

Anil

0

Share this post


Link to post
Share on other sites

make sure the path to the file is correct. It's been a while since I've done this but that could be one reason

0

Share this post


Link to post
Share on other sites
make sure the path to the file is correct. It's been a while since I've done this but that could be one reason

By default the emulator does not support mp3 files. If u are checking the same on actual device, the code will work properly.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

MoDaCo is part of the MoDaCo.network, © Paul O'Brien 2002-2016. MoDaCo uses IntelliTxt technology.