Jump to content


Photo

Audio Player on Smartphone using C#

- - - - -

  • Please log in to reply
11 replies to this topic

#1
sebapi

sebapi

    Newbie

  • Members
  • Pip
  • 13 posts
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, 19 March 2006 - 05:56 PM.

  • 0

#2
Tech

Tech

    Hardcore

  • Members
  • PipPipPipPipPipPip
  • 1,490 posts
  • Devices:E200 2xC500 SP5m Vario
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
http://www.spapps.co.uk

Visit the Spapps UK Forums!!!
Spapps UK Forums [new]
Spapps UK Forums alternative link
^^^ CLICK ME ^^^

Current Projects:

DAR~ling update tba*
WMP Remote** (need new ideas!!)

TV Remote codenamed meetu (postponed)
mini PC Controller codenamed mawk

#3
sebapi

sebapi

    Newbie

  • Members
  • Pip
  • 13 posts
I using .NET CF 2.0
I testing this application on default emulator for smartphone (.NET 2005)

I'll check your solution.
Thx

  • 0

#4
sebapi

sebapi

    Newbie

  • Members
  • Pip
  • 13 posts
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

#5
rogueqd

rogueqd

    Regular

  • Members
  • PipPip
  • 64 posts
  • Devices:Nokia 6500 Slide
Have you provided the full path to the file?

  • 0

#6
sebapi

sebapi

    Newbie

  • Members
  • Pip
  • 13 posts

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

#7
Tech

Tech

    Hardcore

  • Members
  • PipPipPipPipPipPip
  • 1,490 posts
  • Devices:E200 2xC500 SP5m Vario
\ << 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
http://www.spapps.co.uk

Visit the Spapps UK Forums!!!
Spapps UK Forums [new]
Spapps UK Forums alternative link
^^^ CLICK ME ^^^

Current Projects:

DAR~ling update tba*
WMP Remote** (need new ideas!!)

TV Remote codenamed meetu (postponed)
mini PC Controller codenamed mawk

#8
StephenL

StephenL

    Newbie

  • Members
  • Pip
  • 4 posts
  • Devices:i-mate SP5m

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

#9
Tech

Tech

    Hardcore

  • Members
  • PipPipPipPipPipPip
  • 1,490 posts
  • Devices:E200 2xC500 SP5m Vario
unfortunately not, that is only possible I believe in Windows and the WMP SDK, not on Windows Mobile

  • 0
http://www.spapps.co.uk

Visit the Spapps UK Forums!!!
Spapps UK Forums [new]
Spapps UK Forums alternative link
^^^ CLICK ME ^^^

Current Projects:

DAR~ling update tba*
WMP Remote** (need new ideas!!)

TV Remote codenamed meetu (postponed)
mini PC Controller codenamed mawk

#10
aniljain

aniljain

    Newbie

  • Members
  • Pip
  • 1 posts
  • Devices:PDA HP iPAQ

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

#11
Tech

Tech

    Hardcore

  • Members
  • PipPipPipPipPipPip
  • 1,490 posts
  • Devices:E200 2xC500 SP5m Vario
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
http://www.spapps.co.uk

Visit the Spapps UK Forums!!!
Spapps UK Forums [new]
Spapps UK Forums alternative link
^^^ CLICK ME ^^^

Current Projects:

DAR~ling update tba*
WMP Remote** (need new ideas!!)

TV Remote codenamed meetu (postponed)
mini PC Controller codenamed mawk

#12
keyur47831

keyur47831

    Newbie

  • Members
  • Pip
  • 1 posts
  • Devices:WM 6.0

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users