0

您好我正在尝试从本地存储播放 mp4 或 mp3 文件,我知道如何在网络服务器上播放视频。这些文件被下载并存储在我的数据应用程序目录中。

我将详细信息存储在一个名为@Attachments 的数组中。然后我有以下代码来显示每个附件的详细信息。

        @attachments.each do |att|
          if att.MimeType=~ /image/
            %> <img src="<%=att.Data%>" height="100" width="100" alt="Attachment Image"> </img> 
            <br/><br/>
            <% elsif att.MimeType=~ /video/ %>
            <p> File Location - <%= att.Data %> </p>
            <a href="<%= att.Data %>">Play Video - <%= att.Title %></a><br/><br/><%
          else
            %>
            <a href="">View Attachment - <%= att.Title %></a><br/><br/><%
          end
        end
      %>
  <p>

如您所见,我正在检查显示它们的文件类型,我可以毫无问题地显示图像。但是,当我单击链接播放视频时,我收到一个错误加载页面或一个未定义的页面。我知道文件的位置,att.Data 将目录提供给文件,如下所示。/data/data/com.rhomobile.appname/rhodata/apps/filename.extension

这里的任何帮助将非常感谢。

4

1 回答 1

0

We were able to launch a video on click of a hyperlink using following approach:

Attached a jquery script to handle hyperlink click event. On the click event, called a method on the controllers created in RhoMobile and passed the video path as parameter. The code looks like:

<a href="#" id="hyperlink_id">
  <script>
     $('#hyperlink_id').click(function () {
         $.get("/app/Collateral/playmedia?medianame=path_to_video",
           function(data) {});
           }); 
  </script>
  <img src="<%=@collateralHM[iconName].fileName%>">
</a>

In the controller class, the code to handle this looks like:

# GET /Collateral/playvideo
def playvideo
  mediaName = @params['medianame']    
  System.open_url mediaName
end

Hope this helps.

于 2012-07-10T09:18:12.657 回答