Reputation: 2406
I uploaded my 4MB mpe file in App engine blobstore. By retrieving its Blob-key, i tried to play it in jsp file using HTML 5 audio tag. But its not working . The code is given 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>
Upvotes: 4
Views: 1095
Reputation: 80340
Your audio tag's src
attribute should point to an Url where a blob (audio stream) can be downloaded. Instead it just holds a value of the blob key (which is a random string and not an Url, so it does not point anywhere).
It's best to start reading how to serve a blob.
Basically, there isn't an universal blob-serving url, that you could just make a request to and it would serve your blob. You need to create a servlet that serves blobs (see example in the link) and then point the HTML5 audio control to it via src="/path/to/your/blob/servlet?key=<%=request.getParameter("blob-key")%>"
.
Upvotes: 3