Relating to Streaming video in play framework using videojs I'd like to know the best way to stream a video using a Play controller.
I store my videos on the filesystem, and since not every user is allowed to watch every video, I want to restrict access using a controller. So my question is, how can I stream a video from within the controller to the client (running videojs)?
Thank you!
your video is a static content like an image or a .css file. you can use any webserver to serve this content.
if you want control the access there are many techniques. you can create a controller who validate the request, open the video and write bytes in the response. I never try this, for me is much more interesting generate a security token and serve the file over a apache or nginx who use some security plugin.
but if you think in something different than progressive download (like http live streaming or rtmp, rtsp, etc) you need a video server like wowza, flash media server or red5. you can use the same strategy of tokens
Related
I have an endpoint which allow the user to download a PDF. As the PDF generation usually takes more than 20 seconds, I would like to send to the frontend information about the PDF generation progress while we are processing it. I had never used Server-sent events, but I did a simple test in Spring 4.3) and it works fine. But now I don't know how to use it for the PDF download.
Currently I'm writing the PDF in the response ("application/pdf"), but in this case I won't be able to return the object SseEmitter.
Do you have any suggestion for sending a progress stream to frontend and still being able to provide the PDF? Should I use websockets instead of SSE? Maybe two different endpoints? Any suggestion is welcome. :)
My solution was using two different endpoints:
First endpoint: provide the progress stream and persist the PDF content in database
Second endpoint: download the PDF
I don't think I would be happy with this solution if I was not already persisting this PDF content in database anyway, but it was exactly the case, so it was fine. :)
I have tried converting media into 'base64' string then tried to send it. But I think for more long string there will be problem to send that string via web sockets. Kindly share better idea for that.
There are 2 options to do the same,
Peer to peer file transfer:
This uses XMPP mechanism of P2P file transfer and is only suitable for when both users are online. We usually recommend using cloud stored file transfer (see below) unless you have concerns / limitations on server-side.
Cloud stored file transfer:
This uses QB Content API to store files when sent by the user and to retrieve them when other user(s) are ready to download them. The user experience is seamless and allows the user to send/receive files even when the other user is offline, the other user can open the conversation any time and download/play the file.
On client side, typically you want to handle things like progress bars, thumbnails for photos and videos etc.
I read this on Quora and it works
I'm developing a knowledge base java application, where I can store and retrieve annotations with its title, date when the note was created (SQL datetime), content, tags about the annotation, etc.
It can be done easily with a database (I'm using SQL Server 2014), but the main problem is that the server is running on my own PC and it has to be always on and running the SQL Server. Also, I would like to extend the application by storing and retrieving this kind of data on mobile apps for Android and iOS.
Is there any other way to store that type of data in some files so it can be uploaded to some cloud storage like Dropbox ? After storing it on Dropbox, all I would have to do is sync the app with dropbox, get the files and read/write stuff.
UPDATE: Thanks for all the answers they helped me a lot. The best solution for me is to replace SQL Server with SQlite, as Gabe Sechan commented. Now I can make changes on the database without the need of a server running 24/7 and I can use the same database on Android and iOS apps.
You can use just a basic ajax call to pull content from a Dropbox "public" URL.
function(contenturl,intoselector,callback){
if (contentwindow.currenttopic!==contentID){
jQuery.ajax({
type:'GET',
url:'//www.corsproxy.com/'+contenturl,
dataType:'text',
async:true,
success:function(data){
intoselector.html(data);
if (jQuery.type(callback)==="function")
callback();
}
});
}
Notice that this example pulls through corsproxy so that you don't receive any XSS errors, so the url you pass needs to not contain a protocol itself.
If you want to pull a JSON or XML string that is stored in the file, then you might need to play around with the dataType and contenttype options in the ajax call.
This can also be done using Google spreadsheets:
Reading:
Create a spreadsheet and publish it on the web
Use one of the many available Javascript libraries for pulling data from Google spreadsheets:
http://jlord.us/sheetsee.js/ (which uses Tabletop.js)
http://chriszarate.github.io/sheetrock/
Writing:
You can use a Google app script for writing to the spreadsheet (reference) OR
You can create a Google form linked to the spreadsheet and simply fill the form from your mobile app whenever you want to add some data to the sheet (reference)
Of all the cloud services, when it comes to Android, Dropbox's Sync API is one of the easiest to implement. Do you need specific code examples on how to sync with Dropbox?
For a project, I need to be able to stream live audio from a Java server to the browser on the client. My first guess was to use RTMP with a Flash player, my second guess to make use of the HTML5 audio tag. But so far, I've failed to find anything useful (like a library), so does anyone have any pointers on how to do this?
Here's the setup: The sound comes in from a VoIP server as a bunch of PCM samples. From there, it has to go to get to the client, while usually only one client listens to one stream. So I need to be able to send many VoIP streams to several clients, a simple form of authentication would also be nice (like a token or a secret URL where the stream is located at).
So far, I've looked at Red5 (looks to me like one-to-many streaming only) and searched for Java-based RTMP libraries. Any help is gladly appreciated!
What would be a scalable file upload/download system/database?
I'm building a website where users can login, upload images that are private, but truly private. I can't upload them to a map on the harddisk of a server, since that would not scale (what happend if we add more servers?) and it wouldn't be private since everyone could go:
http://127.372.171.33/images/private_picture.png
and download the file.
I am building the project in Play Framework (scala/java)
How do websites like flickr handle these kind of things? Do they put them in a database? And what kind of database would be suitable for this situation?
Thanks for help
I can't tell you how those big sites handle it but putting those images into a database might be one way.
Another way would be to put the files into a virtual filesystem that spans a cluster of servers or distribute them onto different servers and just don't make the directories that contain the images visible to the webserver. Thus nobody should be able to open the image just using the server and the path on that server.
To actually deliver the images you could them implement some streaming service that sends a bytestream to the browser for display (like the webservers would do as well). This service could first check the download permissions for the requested image.