1. Jeggu's Avatar
    I am playing m3u8 files using mediaplyer.

    But ckf url which is present in m3u8 is invalid. i have manipulate that url to get response.

    How can i handle such cases and serve the response

    code:

    public class ViewerActivity extends Activity implements Callback, OnPreparedListener, VideoControllerView.MediaPlayerControl{

    public static MediaPlayer player;
    public static SurfaceView surfaceView;
    public static SurfaceHolder surfaceHolder;
    VideoControllerView controller;
    boolean isPaused = false;
    @override
    protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_videoviewer);
    player = new MediaPlayer();
    //controller = new VideoControllerView(this);
    surfaceView = (SurfaceView)findViewById(R.id.videoSurface);
    surfaceHolder = surfaceView.getHolder();
    surfaceHolder.addCallback(this);
    player.setOnPreparedListener(this);

    Intent intent = getIntent();
    String url = intent.getStringExtra("URL");

    try {
    player.setAudioStreamType(AudioManager.STREAM_MUSIC);
    player.setDataSource(this, Uri.parse(url));
    } 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();
    }
    }
    @override
    public void onPrepared(MediaPlayer mp)
    {
    // TODO Auto-generated method stub
    int videoWidth = player.getVideoWidth();
    int videoHeight = player.getVideoHeight();
    android.view.ViewGroup.LayoutParams lp = surfaceView.getLayoutParams();
    lp.width = videoWidth;
    lp.height = videoHeight;
    surfaceView.setLayoutParams(lp);
    mp.start();

    }
    @override
    public void surfaceCreated(SurfaceHolder holder) {
    player.setDisplay(holder);
    if (isPaused) {
    player.start();
    isPaused = false;
    }
    else
    player.prepareAsync();

    }
    }
    10-31-2016 04:47 AM
  2. Rukbat's Avatar
    You're mixing 2 things - an inability of the code to access a valid, but syntactically incorrect, URL and an invalid URL. You can't access an invalid URL, any more than you can go to the house between two adjacent houses ("invalid URL" means that there's no authoritative server that has that URL, so you can't get its IP address.)

    Could you reword the question?
    10-31-2016 12:42 PM

Similar Threads

  1. Replies: 1
    Last Post: 03-23-2017, 12:41 PM
  2. Is there any way to do this ringtone trick?
    By AC Question in forum Ask a Question
    Replies: 1
    Last Post: 10-31-2016, 01:26 PM
  3. Is there any problem to connect L2TP / IPSec Vpn
    By AC Question in forum Ask a Question
    Replies: 1
    Last Post: 10-31-2016, 01:22 PM
  4. how to re-arrange quick settings list in lock screen?
    By AC Question in forum Ask a Question
    Replies: 0
    Last Post: 10-31-2016, 04:40 AM
  5. Why cant i scroll down to my notification scree
    By AC Question in forum Ask a Question
    Replies: 0
    Last Post: 10-31-2016, 12:02 AM
LINK TO POST COPIED TO CLIPBOARD