How to play mp3 file using blob key of blob storage of application engine in jsp file with HTML5 tags?

I uploaded my 4MB mpe file in the App Engine block block. Having received my Blob key, I tried to reproduce it in a jsp file using the HTML 5 tag. But this does not work. The code is below:

<%@page import="com.google.appengine.api.blobstore.BlobKey" %> <%@page import="com.google.appengine.api.blobstore.BlobstoreService" %> <%@page import="com.google.appengine.api.blobstore.BlobstoreServiceFactory" %> <html> <head> <meta http-equiv="Content-Type" content="audio/mpeg3; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <% BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService(); BlobKey blobKey = new BlobKey(request.getParameter("blob-key")); %><%=request.getParameter("blob-key")%> <audio controls="controls"> <source src="<%=request.getParameter("blob-key")%>" type="audio/mp3" /> </audio> </body> </html> 
+4
source share
1 answer

The audio tag src attribute should point to Url, where you can download blob (audio stream). Instead, it simply contains the value of the blob key (which is a random string, not Url, so it doesn't point anywhere).

It’s best to start reading how to use blob .

Basically, there is no universal URL that you could just request, and it will serve your blob. You need to create a servlet that serves blobs (see the example in the link), and then point it to HTML5 audio control via src="/path/to/your/blob/servlet?key=<%=request.getParameter("blob-key")%>" .

+3
source

All Articles