Use html5 video streaming backend for flutter app? - flutter

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.

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.

Related

Is there any way to get the HTML from a web page once the JavaScript is loaded in a Flutter app?

I'm working on a URL preview widget, so I'd like to extract the meta tags from the HTML of a given URL.
However, the problem is that websites like Twitter don't return the entire HTML when they detect there's no JavaScript engine enabled (i.e. doing a GET request from the http package).
So, I'd like to know if there's any workaround for these cases, for example, using some kind of headless browser to get the entire HTML.
Thanks!

pdf download not working on Android with cordova inappbrowser

In my cordova inappbrowser app, pdfs can be downloaded by calling a RESTful service that streams the content to the user's browser (see html snippet below). This works fine on iOS and using Google Chrome directly on Android but not when doing it through cordova inappbrowser. Clicking on the link doesn't do anything. I've tried many of the suggestions here including using gview but no result.
The tag in html is an href (I tried using window.open as well) that evaluates to something like https://xxx/member/get_pdf/217521359ashr868af6as. Using target='_blank' (tried _system also)
where the value after get_pdf is a guid (value above is not the real guid)
The google viewer workoaround that many people propose works fine with a physical pdfs but my files are streamed back from the service above and gview doesn't recognize it as a pdf and shows error 'preview not available' and its not an option to store them physically. Is there some specific header to set to make gview recognize the streamed response as a pdf? I set content_type, Content-length, tried adding Content-disposition with a filename also. No go.
Any suggestions appreciated.
Thanks,
Patrick

Show image or video depending on Content-Type in React-Native

I would like to show to the user, in my react-native app, an element reachable on a specific url such as: https://s3-eu-west-1.amazonaws.com/somebucket/somekey
This object has a Content-Type that can be image/jpeg or video/mp4.
If it is an image, it has to be printed in an <Image> component from https://facebook.github.io/react-native/docs/image.html.
If it is a video, it has to be shown in a <Video> component from https://github.com/react-native-community/react-native-video
What is a clean way to show this media without downloading it in a first place (the video can be seen as a stream in <Video>) and without knowing its Content-Type?
Right, the solution that I have found is to do a HEAD request on the media to get the Content-Type and then accessing it from the proper React component. Would you have a better solution to avoid this HEAD request?

How to load images using HttpClient API

I have one requirement. I need to access one of our servers (web site) and need to read the content using the URLs and render it on the browser.
In our Application, I am using HttpClient API to access the web pages of one server (http://10.x.xxx.87). I am able to get html content/ web pages in the form of HttpResponse of HttpClient API. The content is sent from my application to the client, where the content is rendered in the browser.
Some of the lines from response,
href="/web/common/images/favicon.ico" type="image/x-icon"
href="/web/common/css/login.css" type="text/css
href="/web/common/css/overlay.css" type="text/css"
This href is pointing to the server I am referring from my application. I think this href location is trying to find the images or css files in my local server. I want the images to be read from the server which is I am accessing from my application.
How to solve this issue ? Help would be appreciated.
I was able to solve this issue. When the client request for the following image, href="/web/common/images/favicon.ico" type="image/x-icon", I am using servlet to read the response from other website.

Need to let user upload video using GWT

I need to let users upload videos in GWT site, and after uploading I should allow them to preview it. I don't need any controls, just a play and stop button would be enough so that I can show them a preview?
Uploading the video to your server is the easy part - that's what the FileUpload Widget is for. You just need to write some sort of end point on the server side - a servlet, PHP script, etc. that will receive the file and store it somewhere.
The tricky part is the preview - AFAIK, you need a media streaming server for that. The only free and good one I know is Red5 (site1, site2, site3 - don't know which one is the current one =_=).
An alternative would be to use an exisiting media streaming site that exposes an API for users to upload videos - like YouTube API. The docs show how to upload a file (directly from the user, or from your server) to the YouTube service - in return you'll get a link or HTML code to embed on your site.