0

I'm new to android and trying to play video in android having three different kind of videos in a playlist(For front end user all are same kind of videos but on back end three different sources are used) one is youtube video 2nd is dailymotion and 3rd one is a MP4 video. Right now i'm running Youtube/Dailymotion using intent

 Intent intent= new Intent(Intent.ACTION_VIEW);        
intent.setDataAndType(Uri.parse(URL), "video/*");
            startActivity(intent);

This working perfectly fine for Youtube and DailyMotion video but for MP4 it is taking too much time.

is there any way to play all types of videos in a single video player provided this videos are lengthy (more then 40-50M duration).

Thanks in advance.

NoNaMe
  • 6,020
  • 30
  • 82
  • 110
  • Can you explain what you mean by 'taking too much time' - do you mean the video is slow to start up? – Mick Jan 15 '18 at 12:26
  • you can't play most part of online videos in custom player. Youtube doesn't allow that. What exactly `it is taking too much` means? – Vladyslav Matviienko Jan 15 '18 at 13:35
  • @Mick, yes it take too much time to startup – NoNaMe Jan 16 '18 at 11:01
  • @VladMatvienko, when i try to play a MP4 video it take too much time to startup, i think Android media player loads the video first and then play the video – NoNaMe Jan 16 '18 at 11:02

1 Answers1

0

It looks like you are passing the URL of the YouTube and DailyMotion videos to the intent, which will point to a HTML page which includes a player with the link to the relevant video.

This will then use the YoutTube or DailyMotion player to play the video, generally leveraging the browsers HTML5 player these days also - the video itself will be available in multiple bit rates on their servers and will use ABR to allow it start quickly and to ensure the quality matches the available network conditions and device type.

If you are simply passing a direct URL to a statically hosted MP4 video then there are two key things that would likely account of the delay starting:

  • faststart - the MOOV header 'atom' in an mp4 file is at the end of the file as standard. If you want to stream the video then it is better to move it to the start to avoid having to download the entire video before starting. See here for more info and an example tool to move the MOOV atom to the start: http://multimedia.cx/eggs/improving-qt-faststart/
  • ABR - as mentioned above most large streaming services will use ABR to stream video. This not only allows the quality be selected to match the conditions, but it allow allows the video start at a low bandwidth for quick startup, and then step up through the quality levels as the video progresses. You can often see this effect when you start a YouTube, NetFLix etc video. See here for an example and more info: https://stackoverflow.com/a/42365034/334402
Mick
  • 24,231
  • 1
  • 54
  • 120