You need to create it in the activity. On Thu, Apr 28, 2011 at 12:30 AM, droid-stricken <[email protected]> wrote:
> Thanks. > So, any idea on how to associate the view created in the activity with > the mediaplayer instance created in the service. > It's not an issue for playing audio files but for video files, i need > a surface to render it :( > > I am sure ppl must have faced this issue - it appears pretty commonly, > i believe. > Thanks. > > > On Apr 27, 11:18 pm, Dianne Hackborn <[email protected]> wrote: > > 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 > -- 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

