NO,
Its not working.
It gives this kind of error..
"The Method create (Context, int) in the type Mediaplayer is not
applicable for the arguments (A, int)..
I think the problem is class A is not extended from Activity class.
That's why its not working. So I don't know how to play sound in this
scenario. Because I got sound in another class which is extended from
Activity Class.
If u can suggest me any code which has scenario like me, I might solve
my problem.
Thanks for your help..
On Dec 7, 2:06 pm, AndroidGeek <[EMAIL PROTECTED]> wrote:
> MediaPlayer menusound = MediaPlayer.create(C.this ,R.raw.eat);
>
> I doubt "C.this" instead try following
>
> MediaPlayer menusound = MediaPlayer.create(this ,R.raw.eat);
>
> directly use "this" not "C.this"
>
> Hope it will help
>
> NJoy :)
>
> On Dec 7, 6:00 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi, In my program I have one class which looks like this
>
> > public class A extends B{
> > ............}
>
> > Here Class A is my application class and it Extends Class B. Class B
> > is not an Activity class provided by Android. And class B has extended
> > View.
>
> > Now the problem is beacuase of this structure I am not able to do
> > certain asctivities like Playing Music, creating new intent as for
> > that I have to extend Activity class in Class A.
>
> > So I don't how I can do that.
>
> > I have implemented one solution to play music .
>
> > I created other class file which has code to play music and I have
> > created object of it in Class A. But it is also not working.
> > The code in class which implmented looks like this.
>
> > public class c extends Activty
> > {
> > public void mediaplay()
> > {
> > try
> > {
> > MediaPlayer menusound = MediaPlayer.create
> > (C.this ,R.raw.eat);
> > menusound.start();
> > }
> > catch (Exception e)
> > {
> > Log.e("Sound", "error: " + e.getMessage(), e);
> > }
> > }
>
> > }
>
> > and i m creating its object in class A using this:
>
> > C o = new C();
>
> > and I use this o object in class A like this:
>
> > 0.mediaplay();
>
> > But when it is called in C, MediaPlayer.create thorws null pointer
> > exception.
> > So how can I solve this?
>
> > It will solve some of my problems.
> > Thanks,
> > Mitul
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---