• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Surface View Player

techker

Well-Known Member
Hey guys, i started to make my own tv app cause wanted to add my idea's..lol

so i got lots of it going but stuck on this surfaceview issue

1.when i click a link the screen gow's black then loads the video?

i think i found it. by adding:
Java:
@override
public void surfaceDestroyed(SurfaceHolder arg0) {
    if (mediaPlayer != null) {
        mCurrentVideoPosition = mediaPlayer.getCurrentPosition();
        mediaPlayer.release();
        mediaPlayer = null;
    }
}

2.when i press back to go back to the main screen ,seems like it created layers everytime i click a link...
is there a way to destroy the previous and make a new one every click?to avoid that..


Java:
@Override
    public void surfaceCreated(SurfaceHolder arg0) {
        if(mStream_id != null){
            String contentUri = Url + "live/" + username + "/" + password + "/" + mStream_id + ".ts";
            try {
                mediaPlayer = new MediaPlayer();
                mediaPlayer.setDisplay(vidHolder);
                mediaPlayer.setDataSource(contentUri);
                mediaPlayer.prepare();
                mediaPlayer.setOnPreparedListener(this);
                mediaPlayer.setOnBufferingUpdateListener(this);
                mediaPlayer.setOnCompletionListener(this);
                mediaPlayer.setScreenOnWhilePlaying(true);
                mediaPlayer.setOnVideoSizeChangedListener(this);
                mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
            } catch (IllegalArgumentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (SecurityException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalStateException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }
    }
 
Last edited:
Back
Top Bottom