Search code examples
androidandroid-intenturimimestart-activity

using default media player to open stream from an Ip in android using uri


I'm trying open this stream in my android app using the default media player but all of my media players got error (e.g. MX Player, and VLC Player).

The Code is:

Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("http://iutv.iut.ac.ir:5657/tv2.flv");                      
intent.setType("video/*");
startActivity(intent)

And the error is :

VLC encountered an error with this media.
Please try refreshing the media library

But when I enter the link on chrome web browser it can open the link with both MX Player and VLC Player properly


Solution

  • This works for me

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.parse("http://iutv.iut.ac.ir:5657/tv2"), "video/*");
    startActivity(intent);
    

    But if your problem still occurring ,take a look at here :

    VLC encountered an error with this media Android