Android: how to play audio and video from app

I was looking for a way how to play video and audio streams from Internet from my app.
There are several ways how to do it and some of them worked for me.

1. Play in inner VideoView.
The solution I found here how to play video from url

in your layout xml set the following:

This method didn’t work for me pretty well, because I tried to play 1 hour mp4 file, which was buffered too long time and then played really slow.

2. Play in installed Media Player.
This solution is pretty nice and very simple. Found here Launch ACTION_VIEW Intent to play mp4

In this case external media player will be used. Additionally, user will be able to select preferred media player to play this video in case there are several of them installed.
To play mp3 file, do the following code.