Wednesday, April 27, 2011

[android-developers] Obtaining access to the surfaceView instance

Hi,

I have an activity -
public class mainActivity extends Activity {

private SurfaceView sv;

@Override
public void onCreate(Bundle savedInstanceState) {
sv = (SurfaceView) findViewById(R.id.video_surface);

.....
}
}

I have a service -

public class VideoService extends Service {

private static MediaPlayer mPlayer;

@Override
public void onCreate() {
super.onCreate();
mPlayer = new MediaPlayer();
SurfaceHolder holder = ((SurfaceView)
findViewById(R.id.video_surface)).getHolder();
player.setDisplay(holder);
}
}

Is this a correct way to set the surface holder for the video
mediaplayer?

If yes, the problem is i cannot do findViewById from within the
service class. Any idea how to solve that part?

I wish the mediaplayer instance to be part of the service so that any
activity can issue play/pause commands and the service will execute
the activities command.

Please help.

Thanks

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate