Home > Android > Android: Counter-Strike 1.6 SoundBoard released

Android: Counter-Strike 1.6 SoundBoard released

January 15th, 2010 mat Leave a comment Go to comments

A soundboard is a very simple application to make, and I was given the idea to make a counter-strike 1.6 version by a friend. It seemed like a good idea as no one had made one yet, and it’s quite hard to find something that hasn’t already been done before.

counter-strike 1.6 soundboard promo image

counter-strike 1.6 soundboard

The buttons are aligned in a grid view, with the buttons made transparent so that the background can be seen.

screenshot of counter-strike 1.6 soundboard android application

screenshot of counter-strike 1.6 soundboard

another screenshot of counter-strike 1.6 soundboard android application

screenshot of counter-strike 1.6 soundboard

I am very pleased with the final look of the app, however it was getting poor reviews due to people wanting to save the sounds for use as a ringtone. To alleviate this problem I have updated the app to have this option as a context menu avaliable by long pressing on a button. This will then save the file on the sd card and update the mediastore to tell android a new ringtone and notification has been added.

The code to load a ringtone into android from an application is shown below. If you see any problems with this code, or have an improvements please let me know!

File k = new File(path, filename);

ContentValues values = new ContentValues();
values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath());
values.put(MediaStore.MediaColumns.TITLE, filesnames[pos]);
values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/wav");
values.put(MediaStore.Audio.Media.ARTIST, "cssounds ");
values.put(MediaStore.Audio.Media.IS_RINGTONE, true);
values.put(MediaStore.Audio.Media.IS_NOTIFICATION, true);
values.put(MediaStore.Audio.Media.IS_ALARM, true);
values.put(MediaStore.Audio.Media.IS_MUSIC, false);

//Insert it into the database
this.getContentResolver().insert(MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath()), values);

Ratings, reviews, feedback and feature requests are most welcome.

Download Link

Android Market Link (For android phones)

Bookmark and Share
Categories: Android Tags: , , ,
  1. Jason
    January 22nd, 2010 at 21:53 | #1

    Hello Mat,

    I have been admiring your soundboard app and wondering just how you got the context menu, etc set up to allow the saving of tones. I am working on an idea for an app of my own and cannot get it to work. There is not enough src in your post for me to figure out what should be done beforehand. Could I see the src for the entire class?

    Any help would be greatly appreciated :)

    Thanks,
    -Jason

  2. January 23rd, 2010 at 12:37 | #2

    Jason,

    Thanks. I created the buttons dynamically and added them to a gridview. For each of them I use “registerForContextMenu(btn);” then I added the options to the context menu

        @Override
        public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {
    	super.onCreateContextMenu(menu, v, menuInfo);
    		menu.setHeaderTitle("Ringtone Actions");
    		menu.add(0, v.getId(), 0, "Save as Ringtone");
    	}
    	

    And then set the even to occur on the selection of this context menu.

        @Override
    	public boolean onContextItemSelected(MenuItem item) {
    	int x = item.getItemId();
    		saveas(x);
    		return true;
    	}
    

    That should probably be enough code to explain it? I might post a short tutorial on it as I would probably do a better job of explaining it then. Hope this helps.

    Mat

  3. Jason
    January 24th, 2010 at 18:24 | #3

    Excellent! I had actually figured that piece out just before reading this post :)

    For the resource > ringtone part, did you write to the sdcard before setting the ringtone or is there a way to inject the tone straight in?

    I am trying to figure out that entire process right now…

    Thanks for your reply :)
    -Jason

  4. Jason
    January 25th, 2010 at 04:04 | #4

    I figured it all out!
    Thanks again for your tips along the way :)
    -Jason

  5. January 26th, 2010 at 12:20 | #5

    Yes, I saved it to the SD card also.
    I placed it in /sdcard/media/audio/ringtones/

    Glad you got it working, let me know when your app is out so I can try it.

  6. Steve
    January 26th, 2010 at 22:15 | #6

    I am having trouble getting this working… How does the app know what file it is copying from? I am looking to copy from a package .wav in my raw file.
    Any ideas or more code you could share?

  7. January 26th, 2010 at 23:32 | #7

    @steve, @jason posted an example which is more complete showing how to save the file and then register as a ringtone:
    http://www.stealthcopter.com/blog/2010/01/android-saving-a-sound-file-to-sd-from-resource-and-setting-as-ringtone/

  8. Chris
    February 13th, 2010 at 16:22 | #8

    I’m making a sound board for a game. I liked how you had your buttons. I wanted users to see my background so i set the button transparencies to ’0′, but how did you get the look of yours? Did you use a drawable source?

  9. February 13th, 2010 at 22:51 | #9

    I created an xml file for the button which uses png images with transparency, I don’t think you need to set anything special for the button then. Let me know if you need an example and I’ll whip something up for you. Also let me know when you release your app and I’ll have a play with it :)

  10. Chris
    February 15th, 2010 at 15:50 | #10

    I acturally figured how to do it.. thank you though.. my main issue is trying to set up the option to let users save as ringtones and such.. main problem is my buttons get created from an adapter..

    acturally the first version of the app is out there, its a Call of Duty MW2 soundboard…

  11. February 15th, 2010 at 16:07 | #11

    Yes, my buttons are setup in the same manner. I’m planning a writing brief tutorial on it, but I have lots of work at the moment. I will check out your app shortly!

  12. Chris
    February 15th, 2010 at 19:18 | #12

    @mat
    ya I’m working to re-do the current app with an update, it’s changed alot since that one was published…

    so where about did u involve the ringtone? I tried to work with it in the button adapter but seems it only wants to work when its extended from Activity…

  13. February 15th, 2010 at 22:01 | #13

    I used “class ButtonAdapter extends BaseAdapter” which then calls a custom OnClickListener “class MyOnClickListener implements OnClickListener”. Then using this custom OnClickListener to call my ringtone function.

  14. Chris
    February 16th, 2010 at 18:13 | #14

    think you should put up a full soundboard tutorial LOL

  15. Chris
    February 26th, 2010 at 17:24 | #15

    just updated the app if you still wanted to check it out.. thanks

  16. February 26th, 2010 at 18:30 | #16

    Yeah, I checked it out the tabs are nice, the button gets horribly pixelated on the last two tabs as they only contain on item though. You make much from the adverts?

  17. Chris
    February 26th, 2010 at 19:25 | #17

    eh.. not a great deal… lol…

  18. Chris
    February 26th, 2010 at 19:28 | #18

    i almost have my ringtone/notifications working.. but when i long click it force closes.. dang im soo close LOL

  19. May 11th, 2010 at 04:18 | #19

    mat I have been looking at all of the code to get save to ringtone and notifications working and I can only get the context menu working… could you please email me so I can ask you a few questions??? I would really appreciate that sooo much!!

  1. June 16th, 2010 at 00:04 | #1
// unused langs // // // //