Problem on play audio files one by one

All your problems with Audio, Video and Images.

Problem on play audio files one by one

Postby wseries » Mon Feb 28, 2011 5:47 pm

Hey guys, im new to android developer and i have a problem in my project.

i have small auido files in the raw folder and what i want is when i retrive song number from sql it should bring me the songs and play these songs one by one, not at the same time. Is there any solution or source code example ?

Thank you
wseries
Freshman
Freshman
 
Posts: 7
Joined: Mon Feb 28, 2011 1:54 am

Top

Re: Problem on play audio files one by one

Postby Kerbik » Tue Mar 01, 2011 9:43 am

I'm not very sure what exactly you want achieve, but ...

how i understand this:

you have 15 short mp3 in raw folder .. by sql you will get ids of that

you want play first mp3, after it ends you want play second after that next .. next .. next until last file right?

well i have one idea how to achieve that...

you can do there cycling thread which will check if is Mediaplayer playing if yes, nothing will happen if not it will change source and start playing new song ....

for sample how to make any cycle you could use this (its for streaming mp3 on 1.5 and earlier versions of android but you can find there what i typed .... )

here is url
http://blog.pocketjourney.com/2008/04/04/tutorial-custom-media-streaming-for-androids-mediaplayer/

and here is example of cyclyng copied from that url

Code: Select all
public void startStreaming(final String mediaUrl, long mediaLengthInKb, long mediaLengthInSeconds) throws IOException {

   this.mediaLengthInKb = mediaLengthInKb;
   this.mediaLengthInSeconds = mediaLengthInSeconds;

   Runnable r = new Runnable() {

      public void run() {
         try {
             downloadAudioIncrement(mediaUrl);
             } catch (IOException e) {
                  Log.e(getClass().getName(), “Initialization error for fileUrl=” + mediaUrl, e);
                  return;
              }
         }
       };
   new Thread(r).start();
}


you could change it to code which should help to you, you can start this cycle when Mediaplayer is created and check byt Mediaplayer.isPlaying(); if it is playing sound or not....

I'm sorry for minimum informations i provided to you, I'm still newbie in programmating so that is reasno why I'm not sure if this code is properly solution but at least it should be one of possible solutions...

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

Re: Problem on play audio files one by one

Postby wseries » Tue Mar 01, 2011 7:04 pm

Kerbik, thank you very much for your helping. I hope it will work. thanks again.
wseries
Freshman
Freshman
 
Posts: 7
Joined: Mon Feb 28, 2011 1:54 am

Re: Problem on play audio files one by one

Postby wseries » Fri Mar 04, 2011 12:58 am

I couldnt do it. Actually i want to create my own tts. i recorded phenomes as mp3. also i want to cmake for different languages which not supported by android tts engine.
1-as input text welcome to newyork.
2- remove spaces and split it
welcometonewyork.
wel come to new york.
3-bringing voices from database
wel.mp3 come.mp3 ...
4- and lastly play them all
how can i do that? please help
thanks
wseries
Freshman
Freshman
 
Posts: 7
Joined: Mon Feb 28, 2011 1:54 am

Re: Problem on play audio files one by one

Postby Kerbik » Fri Mar 04, 2011 9:30 am

Hello,
like i said i'm new to programming and this task needs a lot of experience (from my point of view)

I don't know how to remake it into by step 2,

3) i just will be studying databases in next few weeks :)

4) this step should't be that hard...

when you determine which songs you need to play, it should not be quite hard...
create cycle which check amount of media players required / or you can have prepared 2 and switch them /

check if mediaplayer is playing and start playing next one ... for this can be used sample from streaming media player class from my previous post =)

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

Re: Problem on play audio files one by one

Postby wseries » Fri Mar 04, 2011 1:08 pm

Kerbik thanks for your advice again. I will try work on this issue again
wseries
Freshman
Freshman
 
Posts: 7
Joined: Mon Feb 28, 2011 1:54 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 11 guests