Sound Problem

All your problems with Audio, Video and Images.

Sound Problem

Postby and.modi » Sun Dec 07, 2008 2:04 am

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.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public class C extends Activty
  3.  
  4. {
  5.  
  6.       public void mediaplay()
  7.  
  8.        {
  9.  
  10.        try
  11.  
  12.            {
  13.  
  14.                    MediaPlayer menusound = MediaPlayer.create (C.this ,R.raw.eat);
  15.  
  16.                menusound.start();
  17.  
  18.            }
  19.  
  20.           catch (Exception e)
  21.  
  22.           {
  23.  
  24.                  Log.e("Sound", "error: " + e.getMessage(), e);
  25.  
  26.           }
  27.  
  28.       }
  29.  
  30. }
  31.  
  32.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4

and i m creating its object in class A using this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. C o = new C();
  3.  
  4.  
Parsed in 0.029 seconds, using GeSHi 1.0.8.4


and I use this o object in class A like this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. o.mediaplay();
  3.  
  4.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4

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
and.modi
Junior Developer
Junior Developer
 
Posts: 14
Joined: Sat Jul 26, 2008 9:17 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 9 guests