This problem could be solved with the help of the library https://github.com/mrmaffen/vlc-android-sdk
<FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="false" > <FrameLayout android:id="@+id/player_surface_frame" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:foregroundGravity="clip_horizontal|clip_vertical" tools:ignore="true"> <SurfaceView android:id="@+id/player_surface" android:layout_width="480dp" android:layout_height="360dp" /> </FrameLayout> </FrameLayout>
public void play(String address) { mSurfaceView = (SurfaceView) globalView.findViewById(R.id.player_surface); mSurfaceHolder = mSurfaceView.getHolder(); mSurfaceFrame = (FrameLayout) globalView.findViewById(R.id.player_surface_frame); mMediaUrl = new String(address); try { mLibVLC = new LibVLC(); mLibVLC.setAout(mLibVLC.AOUT_AUDIOTRACK); mLibVLC.setVout(mLibVLC.VOUT_ANDROID_SURFACE); mLibVLC.setHardwareAcceleration(LibVLC.HW_ACCELERATION_FULL); mLibVLC.init(getContext()); } catch (LibVlcException e){ Log.e("TAG", e.toString()); } mSurface = mSurfaceHolder.getSurface(); mLibVLC.attachSurface(mSurface, VideoStreamFragment.this); mLibVLC.playMRL(mMediaUrl); }