4

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>
4

1 回答 1

3

您的音频标签的src属性应指向可以下载 blob(音频流)的 Url。相反,它只保存 blob 键的值(这是一个随机字符串,而不是 Url,因此它不指向任何地方)。

最好开始阅读如何为 blob 提供服务

基本上,没有一个通用的 blob 服务 url,您只需向它发出请求,它就会为您的 blob 服务。您需要创建一个为 blob 提供服务的 servlet(请参阅链接中的示例),然后通过src="/path/to/your/blob/servlet?key=<%=request.getParameter("blob-key")%>".

于 2012-06-14T06:42:15.060 回答