Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,771,756 Members 40,982 Now Online
XDA Developers Android and Mobile Development Forum

[App][Apr 24 2010] PlaySound - Command line sound player / vibrate for scripting

Tip us?
 
thx1200
Old
(Last edited by thx1200; 7th October 2010 at 06:46 PM.)
#1  
thx1200's Avatar
Recognized Developer - OP
Thanks Meter 49
Posts: 872
Join Date: Apr 2006
Location: Raleigh, North Carolina
Smile [App][Apr 24 2010] PlaySound - Command line sound player / vibrate for scripting

Description
I had a need to play a sound and vibrate my phone in a script-like setting (specifically, actions in the amazing Rhodium Keyboard Controller app). I couldn't find a simple app to let me do this. So I wrote one! It took about 10 minutes. :) I now share this with you because I'm sure somebody else has had the same need.

Tip Jar
Like this app? Want more like it? Tip a buck (or Euro or Pound or whatever) or two to help the author out! Click here to make a safe donation via PayPal.

To Use
1. Copy the PlaySound.exe file somewhere, like \Windows.
2. In your script or LNK, use command line arguments to tell it what to do. A single command line argument means that you are specifying a path to a sound to play. It will only play WAV files (sorry if you want WMA or MP3 etc you will need to convert). If you specify two arguments, it means you want to vibrate the phone. The first argument is the LED index of the vibrate (usually 1), and the second is length of time to vibrate in milliseconds.
3. If you do not specify command line arguments, or specify invalid ones (wrong path, negative number, etc.), it will fail without any notice (run, then immediately quit). This app will not tell you when something goes wrong.

Examples
Play the loudest.wav sound in \Windows
playsound.exe \windows\loudest.wav

Vibrate a Touch Pro 2 for half a second
playsound.exe 1 500

Notes
Remember to enclose the path in quotes if you have spaces in the path name to your file, or else PlaySound will interpret it as multiple arguments and think you want to vibrate. (for example, playsound.exe "\Program Files\My App\Sound.wav")

License
This app is released into the public domain with no warranty. That means you can redistribute it at will and do not even have to give me credit. I would appreciate credit, though. ;) Enjoy!

Requirements
At least WM5 (fully compatible with WM6/6.1/6.5). It should work on touchscreen and non-touchscreen devices both, but I haven't tested it on a non-touchscreen device yet.

Updates
It's highly doubtful that I will ever update this app. If you need more features, feel free to use the source and compile your own!

Downloads
Attached to this post is the app and full source code.
Attached Files
File Type: zip PlaySoundExe.zip - [Click for QR Code] (1.7 KB, 397 views)
File Type: zip PlaySoundSource.zip - [Click for QR Code] (3.6 KB, 269 views)
Avian Waves aka thx1200
http://www.avianwaves.com

Samsung Galaxy S4 / Sprint

Android Apps: Coming soon!
Legacy Windows Mobile Apps (no longer supported): Avian Play / Mute4 / ReRemind / BattLineSvc / ZoomBarPlus / PlaySound / TouchFlo Detacher / Mobile Shell 3 Toggler / iContact AE
 
mike2nl
Old
(Last edited by mike2nl; 6th October 2010 at 08:15 PM.)
#2  
mike2nl's Avatar
Senior Member
Thanks Meter 535
Posts: 3,603
Join Date: Jul 2009
Location: Near Utrecht
Hi thx1200,

i have seen the following:

Quote:
if (argc >= 3)
else if (argc >= 2)
But not argc = 1 so as in playsound.exe 1 500. Where you have done it, or i am blind .

BTW:
good, easy and clean. Short gec
Sensation XE: 光盤 6, PYDX & AIO latest
SGT 7 3G: CM 11, 4.4.2 storm31
HD2: 光盤 3.7, marc 0.2.3
Teams: CHTBeta, CHTArt, CD
Apps: 3D Photo Browser Mods
Android Test Links: USB Echo
 
ephestione
Old
(Last edited by ephestione; 6th October 2010 at 06:58 PM.)
#3  
ephestione's Avatar
Senior Member
Thanks Meter 40
Posts: 2,002
Join Date: Mar 2008
Location: Rome
Quote:
Originally Posted by mike2nl View Post
Hi thx1200,

i have seen the following:



But not argc = 1 so as in playsound.exe 1 500. Where you it done, or i am blind .

BTW:
good, easy and clean. Short gec
if argc is either 2 or 3 they do their thing and return 0, otherwise the routine follows and returns -1, that's the trigger

EDIT: wait, I think I just said a very stupid thing... this is my second guess: for not knowing ANYTHING about wm programming, I think that argc is the number of arguments passed to the program (as in ARGument Count), while argv[] is the (ARGument Value) index for those parameters
Samsung Galaxy S4

Ephestione's HQ: my hobby
Studio MS: my profession
reecycle.it: oggetti in regalo, riciclo e freecycling

DONATE... not money!! 1GB is ok, you won't spend a penny, and instead get 3GB for yourself
 
thx1200
Old
(Last edited by thx1200; 7th October 2010 at 06:46 PM.)
#4  
thx1200's Avatar
Recognized Developer - OP
Thanks Meter 49
Posts: 872
Join Date: Apr 2006
Location: Raleigh, North Carolina
Quote:
Originally Posted by ephestione View Post
if argc is either 2 or 3 they do their thing and return 0, otherwise the routine follows and returns -1, that's the trigger

EDIT: wait, I think I just said a very stupid thing... this is my second guess: for not knowing ANYTHING about wm programming, I think that argc is the number of arguments passed to the program (as in ARGument Count), while argv[] is the (ARGument Value) index for those parameters
You are correct. argc just counts the number of arguments passed to the application. argv contains the arguments. To make it more confusing, the application path is also passed in. So argv[0] is the app path, argv[1] is argument 1, argv[2] is argument 2, etc. So, argc (argument count) is 2 when there is actually one argument passed in (because the first argument is the app path and the second the first argument).

argv is a string array, so you have to convert the string into a numeric value if you want to do numeric processing, and that's what the _ttoi() function does for the LED index and wait value.

And, there you have it. :)
Avian Waves aka thx1200
http://www.avianwaves.com

Samsung Galaxy S4 / Sprint

Android Apps: Coming soon!
Legacy Windows Mobile Apps (no longer supported): Avian Play / Mute4 / ReRemind / BattLineSvc / ZoomBarPlus / PlaySound / TouchFlo Detacher / Mobile Shell 3 Toggler / iContact AE
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes