1. Are you ready for the Galaxy S20? Here is everything we know so far!

Surface View Player

Discussion in 'Android Development' started by techker, Sep 12, 2019.

  1. techker

    techker Well-Known Member
    Thread Starter

    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:
    Code (Java):
    1.  
    2. @override
    3. public void surfaceDestroyed(SurfaceHolder arg0) {
    4.     if (mediaPlayer != null) {
    5.         mCurrentVideoPosition = mediaPlayer.getCurrentPosition();
    6.         mediaPlayer.release();
    7.         mediaPlayer = null;
    8.     }
    9. }
    10.  
    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..


    Code (Java):
    1.  
    2. @Override
    3.     public void surfaceCreated(SurfaceHolder arg0) {
    4.         if(mStream_id != null){
    5.             String contentUri = Url + "live/" + username + "/" + password + "/" + mStream_id + ".ts";
    6.             try {
    7.                 mediaPlayer = new MediaPlayer();
    8.                 mediaPlayer.setDisplay(vidHolder);
    9.                 mediaPlayer.setDataSource(contentUri);
    10.                 mediaPlayer.prepare();
    11.                 mediaPlayer.setOnPreparedListener(this);
    12.                 mediaPlayer.setOnBufferingUpdateListener(this);
    13.                 mediaPlayer.setOnCompletionListener(this);
    14.                 mediaPlayer.setScreenOnWhilePlaying(true);
    15.                 mediaPlayer.setOnVideoSizeChangedListener(this);
    16.                 mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    17.             } catch (IllegalArgumentException e) {
    18.                 // TODO Auto-generated catch block
    19.                 e.printStackTrace();
    20.             } catch (SecurityException e) {
    21.                 // TODO Auto-generated catch block
    22.                 e.printStackTrace();
    23.             } catch (IllegalStateException e) {
    24.                 // TODO Auto-generated catch block
    25.                 e.printStackTrace();
    26.             } catch (IOException e) {
    27.                 // TODO Auto-generated catch block
    28.                 e.printStackTrace();
    29.             }
    30.  
    31.         }
    32.     }
     


    #1 techker, Sep 12, 2019
    Last edited: Sep 12, 2019
Loading...

Share This Page

Loading...