You can't do this from a service.  A service is not associated with a UI.

On Thu, Apr 28, 2011 at 12:15 AM, droid-stricken <[email protected]> wrote:

> 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 [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-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" 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-developers?hl=en

Reply via email to