Sample streaming video mediaplayer or how to stream video from url in Android.

Published by Igor Khrupin on

Hi,

I want to share you my sample Android video player. This player can play video from URL. Also below you can download source code of Android Maven project.

My player have individual style. What features does the player have:

  • Nice MediaController. I don’t use MediaController from Android API.
  • New SeekBar style
  • Animation for MedeaController. If user don’t touch screen for the 5 seconds then MediaController slow disapears.
  • Pause playing by click the screen. (Like youtube Android application).

This mediaplayer is not perfect, but it is very good tutorial for newbies. Enjoy!

Here you can see the video:

Download it from github

18 Comments

dexxtr · 19 September, 2011 at 20:26

what type of video files can your player play?

Igor · 19 September, 2011 at 20:34

I use MediaPlayer class from Android API. This player play all MediaPlayer supported formats. I don’t discover this. Here you can read the list of suppoted formats http://developer.android.com/guide/appendix/media-formats.html

KAZIM · 18 November, 2011 at 13:17

Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY

simbu · 24 November, 2011 at 14:01

In this source code video not play the long time. just only 3minutes only play the videos.after received media.getDuration() -illegalstateException error received

jite eghagha · 18 January, 2012 at 00:26

awesome it’s not perfect…. but it worked PERFECTLY! thanks for sharing this code.

Igor · 5 March, 2012 at 09:49

@KAZIM
Maybe you use emulator or device which doesn’t support this code.
I have this problem when use amulator withour Google Maps lib for application which requires it.
Try to create another emulator or use another device

Nick · 5 March, 2012 at 14:35

Hiya, Thanks for your example code. I was tring to use it to stream .mp4 videos but it fails with errors if I give it a url of an mp4.

Any ideas ?

Cheers

Nick

vincentfor0214 · 25 April, 2012 at 18:11

thank you very much

Abhinaw · 11 May, 2012 at 12:18

Good example…..thanks.

lucky · 11 May, 2012 at 15:40

hi, i try this code but android (4.0) emulatore show error massage “Unexception error” then app stop

Bryan Adams · 16 May, 2012 at 15:37

How i playing media file in local mobile. I have added to sd card, but can’t play it. Please help me

adam · 26 June, 2012 at 00:26

I am trying to use this to support streaming media but I am met with:
06-25 16:23:28.133: W/Surface(7943): Surface.finalize() has work. You should have called release() (32642216, 0)
06-25 16:23:28.133: W/MediaPlayer-JNI(7943): MediaPlayer finalized without being released

sahrul · 28 November, 2014 at 07:47

i can’t download your source code 🙁

asiawatcher · 23 August, 2016 at 01:55

anyway we can do this to stream nonstop when the web stream times out and stops ? how can we make this reconnect to stream, everytime thew stream stops ? cheers

RalucaG · 22 June, 2017 at 12:39

Indeed, this is all very useful information, but from what I gather, there are multiple issues and bugs with the codes you offered. If you are looking for an easy way out, you could always try RTMP protocol provided by Streamaxia (https://www.streamaxia.com/openplayer-rtmp-player-android/). Moreover, they offer WebRTC tools and OpenSDK live video streaming library for Android!
Useful links:
https://www.streamaxia.com/opensdk-android-rtmp-library/
https://www.streamaxia.com/streamaxia-webrtc/
Happy coding!

Leave a Reply to Igor Khrupin Cancel reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.