0

I had a node.js server which streamed videos from my local pc to html5 video tags.

I wanted to use this backend to stream videos to my flytter app as well but could find any way to do it.

One solution was to host the file on the server and play it using the video_player plugin.

But I wanted to be able to play it using the same backend whcih responds to a get request containing headers about which block of data is needed and then sends back a response with that data. Any help?

Example html that plays a video:-

<html>
    <title>Welcome</title>
    <body>
        <video controls>
            <source src="http://localhost:8000/movie/0" type="video/mp4"/>
            <!-- fallback -->
            Your browser does not support the <code>video</code> element.
        </video>
    </body>
</html>

Node backend responds with appropriate bloks of data based on GET requests from the player.

asds_asds
  • 990
  • 1
  • 10
  • 19

1 Answers1

0

Well the only data needed is the video streaming link. In your sample it is "http://localhost:8000/movie/0".

Well if you have access to the backend I really advise to you return the request data in Json format but you need to change it in your server application to be able to return html and/or Json data when needed.

If you can't change the server side code one approach is in your flutter app parse the html file and extract the streaming link data by yourself. To do that you can use this flutter plugin to parse the HTML code and access the DOM to extract the video link and use it with video_player plugin as you already know.

Another way is using a webview widget in your flutter app.There is a lot of such plugins available.

Marcos Boaventura
  • 4,641
  • 1
  • 20
  • 27
  • the video_player plugin expects a link to the file itself. What my link does can be found in this question:- https://stackoverflow.com/questions/24976123/streaming-a-video-file-to-an-html5-video-player-with-node-js-so-that-the-video-c – asds_asds Jan 10 '20 at 03:41