It should have worked the way he did it (
http://developer.android.com/guide/topics/media/index.html#playraw). The
exception raised should be of more help.

On Wed, Apr 28, 2010 at 8:23 AM, AJ <ajeet.invinci...@gmail.com> wrote:

> Before starting the media you need to do following things:-
>
> FileDescriptor fd =
> getResources().openRawResourceFd(R.raw.xxx).getFileDescriptor();
> mp.setDataSource(fd);
> mp.setAudioStreamType(AudioManager.STREAM_RING);
> mp.prepareAsync();
>
>
> For more info check this
> http://developer.android.com/guide/topics/media/index.html
>
> Hope this helps you.
>
> Thanks,
> AJ
>
> On Apr 28, 2:59 pm, Mihai Fonoage <fonoag...@gmail.com> wrote:
> > What error do you get?
> >
> > On Apr 26, 7:26 pm, arberb <beqi...@gmail.com> wrote:
> >
> >
> >
> > > This is my script:
> > > public class MainActivity extends Activity {
> >
> > >     @Override
> > >     public void onCreate(Bundle icicle) {
> > >         super.onCreate(icicle);
> > >         this.setContentView(R.layout.main);
> >
> > >         Button myButton = (Button)this.findViewById(R.id.my_button);
> > >         myButton.setOnClickListener(new OnClickListener(){
> > >                @Override
> > >                public void onClick(View arg0) {
> > >                     MediaPlayer mp =
> > > MediaPlayer.create(MainActivity.this,
> > >                               R.raw.xd);
> > >                     mp.start();
> > >                     // i.e. react on the end of the music-file:
> > >                     mp.setOnCompletionListener(new
> > > OnCompletionListener(){
> >
> > >                          // @Override
> > >                          public void onCompletion(MediaPlayer arg0) {
> > >                               // File has ended !!! Wink
> > >                          }
> > >                     });
> > >                }
> > >         });
> > >     }
> >
> > > }
> >
> > > but when I click the button in my app the application crashes. Why
> > > does this happen?
> >
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to
> android-developers@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> > > For more options, visit this group athttp://
> groups.google.com/group/android-developers?hl=en
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> > For more options, visit this group athttp://
> groups.google.com/group/android-developers?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to