Search code examples
androidvideostreamingmedia-playerprotocols

What protocol and how to stream a video that is already streamed- Android


I'm trying to make my app playing some videos from some TV channels that have online broadcasting on their homepages. Apparently I need to know what ** streaming protocol** is appropriate for those kind of videos. Does it mean that I need to know what protocol they are using in their streaming? or should I choose my own protocol? and what should I think about when it comes to choosing?

And final question: I heard that choosing the appropriate class (Media player) or Video view is depended on what protocol it is. is it true? that class has to have support for swiping on the screen.

Thanks in advance.


Solution

  • Firstly it is worth checking that the stream you want to play is actually available for playback - many online TV providers will use encryption and authentication mechanisms so that their video streams can only be played back in an app or browser that a registered user has logged in to.

    Assuming that it is available then you need to check to see what format they make it available in.

    In high level terms streaming video is typically packaged as follows:

    • raw video
    • -> encoded into compressed format (e.g. H.264)
    • -> packaged into container (e.g.mp4) along with audio streams etc
    • -> packaged into adaptive bit rate streaming format (e.g. HLS, Smoothstreaming, MPEG DASH)

    Different devices and different browsers support different encoding, packaging and streaming formats.

    Assuming that you want to use a HTML5 browser, either standalone or in a web view in an app, then the following links provide a good, regularly updated, overview of the which devices and browsers support which encoding and streaming for HTML5 video playback (this is a constantly changing picture so you need to check the current status using links such as these):

    So your steps:

    1. make sure video is available either unprotected or that you have access to encryption keys authentication credentials etc
    2. identify the streaming technology being used, for example by looking at the file type in the URL (e.g. '.mpd' for a DASH format)
    3. Look at the individual video and audio streams within the streaming 'index' or 'manifest' file and check that your device can support them

    You can take a short cut initially by testing the streams you have on your target device in some of the available browser based test players for the different formats, for example for DASH:

    If they play here then you should be able to get them working in your app.