How to pass data with application

All your problems with Audio, Video and Images.

How to pass data with application

Postby mapiko » Thu Feb 10, 2011 10:22 am

Hello


hope you can help me.

I have app that needs to have preinstalled sounds of size 10kB to 100kB. All sounds have to be preinstalled with apk file.

Do anyone know how to do it?

thank you
mapiko
Senior Developer
Senior Developer
 
Posts: 106
Joined: Sat May 15, 2010 5:19 pm

Top

Re: How to pass data with application

Postby Kerbik » Thu Feb 10, 2011 11:35 am

Hello, I'm not sure how do you think word preinstaled

what you can do...

You can:
1) pack your sounds into .apk file you can insert them into res folder and acces to them in code (I will type you more when i will come back home)

2) upload sounds on internet and if will user need them he can download them on SD when it will be required...(this is option but required is connection to internet and i don't know if it is best solution)

I prefer point 1) because if you use propper format of sounds final .apk file isn't much more larger.
Kerbik
Kerbik
Developer
Developer
 
Posts: 30
Joined: Fri May 28, 2010 6:06 am

Re: How to pass data with application

Postby mapiko » Thu Feb 10, 2011 11:46 am

Thank you very much!

I can't wait to see solution for first answer!

Thank you
mapiko
Senior Developer
Senior Developer
 
Posts: 106
Joined: Sat May 15, 2010 5:19 pm

Re: How to pass data with application

Postby Kerbik » Thu Feb 10, 2011 11:53 am

Ok so few informations what i remember from my project :)

you have to create raw folder under res....

you will insert sounds to it and acces to them through Getresources command

you can check this link to find it yourself or wait for me 4 hours :)
http://stackoverflow.com/questions/9391 ... ue-android

Kerbik. :)
Kerbik
Developer
Developer
 
Posts: 30
Joined: Fri May 28, 2010 6:06 am

Re: How to pass data with application

Postby mapiko » Thu Feb 10, 2011 12:04 pm

I can wait :)
mapiko
Senior Developer
Senior Developer
 
Posts: 106
Joined: Sat May 15, 2010 5:19 pm

Re: How to pass data with application

Postby Kerbik » Thu Feb 10, 2011 5:35 pm

OK so here it is ....

for example porposes I wil type it for example.mp3 (my used file has 52kb)

1) under res folder create new folder named raw
2) copy example.wav to it (you can make it by easy drag from explorer and drop it to eclipse folder) , also it can be mp3 or another supported format which you can find on google dev site... :)

on layout you created button with associated onClicklistener...
in onClicklistener you are starting

Code: Select all
Button playraw = (Button) findViewById(R.id.play_raw);
                  play.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               playraw();
            }
         });


ok we just defined that click should call function playraw() so we have to define it you have to place it on bottom part of class before last } symbol ...
Code: Select all
public void playraw(){
      //we will get special number of example.mp3 into variable resources
             int resources = R.raw.example;
       //it will create mediaplayer called rawplayer with predefined path to resource
             MediaPlayer rawplayer = MediaPlayer.create(this, resources);
      //rawplayer will start playing
              rawplayer.start();
}


Attachments: created apk file ...
filesystem of project (you can download it into eclipse by unpacking somwhere you know it is there, then hitting import in eclipse and find propper directory :) it should work :)

I hope this will help you :) .
Kerbik.
Attachments
PlayRaw.zip
Here is filesystem of this project ...
(152.52 KiB) Downloaded 36 times
PlayRaw.apk
This should works :) at least for me it was working!
(62.53 KiB) Downloaded 34 times
Kerbik
Developer
Developer
 
Posts: 30
Joined: Fri May 28, 2010 6:06 am

Top

Re: How to pass data with application

Postby mapiko » Thu Feb 10, 2011 5:39 pm

Thank you very much! :) U helped me a lot.

I had problem with .mp3
mapiko
Senior Developer
Senior Developer
 
Posts: 106
Joined: Sat May 15, 2010 5:19 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 8 guests