androidandroid-intentvlcrtspvlc-android

Android : How to use VLC without exiting current Activity ? (For background audio)


Presumed : VLC for Android is installed on device and works fine.

Actually I can start VLC with my URL and listen an audio stream with real-time capabilities ( < 1 sec ) with that :

 private void startRTSPStreamOnVLC(String ip, String port, String path) {
    final String url = "rtsp://" + ip + ":" + port + "/" + path;

    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setPackage("org.videolan.vlc");
    i.setDataAndType(Uri.parse(url), "video/h264");
    i.setComponent(new ComponentName("org.videolan.vlc", "org.videolan.vlc.gui.video.VideoPlayerActivity"));
    startActivity(i);
}

Problem is, it brings VLC on the screen, causing my application to Pause/Stop and breaks my other way audio stream.

It would be even greater if I could open VLC in a View I could show in my Layout actually.

I know of Services to be used as Activity without GUI, but It would implies changing VLC itself, which I really wish to avoid.

Any secret tip to achieve that ?

-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-'-

EDIT / Answer : As Vikash Kumar Verma said, using LibVLC was the way to go. I had to compile it for my ABI (mips) by following this guide. The most recent example of app I found was this one.

Managed to go down to 550ms delay of my RTSP audio stream running on Windows 7 with VLC as server. I had to go in the Media class and changed line 771 like following :

 addOption(":network-caching=0"); // Was 1500

Solution

  • Yes you can use VLC in your your layout. Have a look at MyVlcPlayer. I have use libVLC library to play video in my application.