Hi,
I am working on streaming player application and the streaming player
is perfectly working fine when run as an activity. now I am trying to
run it as a service and I have to control the progress bar through it
as well .for that purpose I have coded  a MediaService Class extended
it from service.from the logcat I can see service being created and
destroyed.but still this is not working . please advise how can
acheive my goal ? any alternate solution. how can control
UserInterface on Activity re-start or refocus ?

I have initied MediaService class from my main activity like this



 Intent myIntent = new Intent(Application.this, X96MediaPlayer.class);
 
MediaService.setUpdateListener(this,txtstream,imgbtn,playbtn,streambtn,progressbar);
        startActivityForResult(myIntent, 00)  ;


Note I m attaching my UIUpdataListener through static Method



here is my MediaService class

public class MediaService extends Service {

        private static Application MAIN_ACTIVITY;
        StreamingMediaPlayer audioStreamer ;
    private static TextView textStreamed;
        private static ImageButton playButton;
        private static ProgressBar      progressBar;
        private static Button streamButton;
        private static Context context;



        public static void setUpdateListener(Context  lcontext,TextView
ltextStreamed, ImageButton      lplayButton, Button
lstreamButton,ProgressBar       lprogressBar) {
                context = lcontext;
                textStreamed = ltextStreamed;
                playButton = lplayButton;
                progressBar = lprogressBar;
                streamButton = lstreamButton ;

                }



        @Override
        public IBinder onBind(Intent arg0) {
                // TODO Auto-generated method stub
                return null;
        }



        @Override public void onCreate() {
                  super.onCreate();

                  // init the service here
                  _startService();


                }

                @Override public void onDestroy() {
                  super.onDestroy();
                  Log.e("Streaming Media", ""Media Service Killed");
                  _shutdownService();


                }
                private void _startService() {
                        try {
                                Log.e("MediaService", "Media service started");
                                audioStreamer = new 
StreamingMediaPlayer(this,textStreamed,
playButton, streamButton,progressBar);
        
audioStreamer.startStreaming(IStreamPlayer.songUrl,IStreamPlayer.mediaLengthInKb,
IStreamPlayer.mediaLengthInSeconds);


                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }

                }
                private void _shutdownService() {
                        if(audioStreamer !=null)
                        audioStreamer.interrupt();


                }

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

To unsubscribe, reply using "remove me" as the subject.

Reply via email to