StageWebViewBridge 加载包含的资源

发布于 2024-12-04 18:02:27 字数 902 浏览 2 评论 0原文

我的首要任务是使用 StageWebView 类在使用 Flash CS5.5 AIR for iOS 编译的 ipad 应用程序上播放全屏(标准尺寸)1024x768 H264 视频。这工作得很好。尽管没有与 StageWebView 进行通信的官方方式,但我无法在视频播放完毕后“删除”视频。输入启用 AS <=> 的 StageWebViewBridge JS通讯。

我正在尝试解决 iPad(1 或 2)上 Video 类整体性能不佳的问题。在加载 html5 对象的 StageWebView 中播放视频效果非常好(阅读:GPU 硬件解码的 h264)。

我确实需要在 StageWebView 中播放完视频后关闭视频。我正在打包一个以 H264 编码的 .mov 文件,该文件在 webkit 浏览器中运行良好。如果我只是在 StageWebView 中加载一个带有指向任何视频文件的标签的网页,它就可以正常播放。

一旦我引入 StageWebViewBridge,它就会发生变化。他们希望将文件放在 /html 文件夹中。我正在发送各种路径供玩家 src 播放,但不会加载任何视频。该视频名为“a.mov”。我尝试了player.src ='a.mov',或player.src ='html/a.mov',或player.src ='./html/a.mov',甚至使用File类来获取文件。 applicationDirectory 并将文件解析为 .nativePath。无论我在 StageWebView 页面中从 AS 发送什么到 JS,我都无法让它加载视频。

有人知道如何引用嵌入文件吗?我想发送文件从 AS 加载到 JS,并让 JS 重置 html5 元素的 .src 属性。

即使我制作的 File.applicationDirectory 引用也声明文件“存在”,但我永远无法在页面上设置该元素的 .src 属性。好像不太明白。

任何提示将不胜感激。

My priority is to have a fullscreen (standard size) 1024x768 H264 video played on an ipad app compiled with flash CS5.5 AIR for iOS using the StageWebView class. This works perfectly fine. Although with no official way to communicate with the StageWebView, I can't 'remove' the video once it's done playing. Enter StageWebViewBridge which enables AS <=> JS communication.

I'm trying to get around the overall poor performance of the Video class on the iPad (1 or 2). Playing the video inside a StageWebView loading a html5 object works amazingly great (read: GPU hardware decoded h264).

I do need to shut the video off after it's done playing in the StageWebView. I am packaging a .mov file encoded in H264 that plays great in webkit browsers. If I just load a webpage in the StageWebView with a tag pointing to any video file it plays perfectly fine.

Once I introduce StageWebViewBridge it changes. They want files put in a /html folder. I'm sending paths of all kinds for the players src to play and no video ever loads. The video is named 'a.mov'. I tried player.src = 'a.mov', or player.src = 'html/a.mov', or player.src = './html/a.mov' or even using the File class to get the File.applicationDirectory and resolve the file to the .nativePath. No matter what I send from AS to the JS in the StageWebView page, I cannot get it to load the video.

Has anyone figured out how to reference embedded files? I'd like to send the file to load from AS to JS and have JS reset the .src property of a html5 element.

Even the File.applicationDirectory reference I make states the file 'exists', but I can never set the .src property of the element on the page. It doesn't seem to understand.

Any tips would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

滥情稳全场 2024-12-11 18:02:27

我是 stagewebview 桥的制作者...

您评论的所有事情都可以在我的类中完成...在 html 中引用文件的方式是:

<img src="appfile:/yourfile.jpg">

但我想您的问题是您会改变src 是动态的,您不知道如何获取文件的真实路径。

就在今天,我更新了我的库...(一些错误和 android 版本!!!)

我需要有时间上传示例,但首先请查看 wiki 和 javascript 中的此函数:

StageWebViewBridge.getFilePath( path )

想象一下www 目录中有一个名为 video.mp4 的文件(是的,已更改,现在是根目录),您需要使用 jQuery 分配视频的 src...

只需在 JS 中执行此操作:

$('#video').attr('src', StageWebViewBridge.getFilePath('jsfile:/video.mp4') );

在不执行任何操作之前阅读文档,因为它已更改...

如果有帮助的话请告诉我......

I am the maker of stagewebview bridge...

All of the things you comment, can be done with my class.... the way of reference a file in the html is:

<img src="appfile:/yourfile.jpg">

But I imagine the problem for you is that you will change the src dinamically and you don't know how to get the realpath for the file.

Just today I have updated my library... ( some bugs, and android version!!!)

I need to have time to upload the examples, but for an starting point look at the wiki and at this function from the javascript:

StageWebViewBridge.getFilePath( path )

Imagine you have a file inside the www dir ( yes that have changed and now is the root dir ) named video.mp4, and you need to assign the src of the video with jQuery...

Simply do this in JS:

$('#video').attr('src', StageWebViewBridge.getFilePath('jsfile:/video.mp4') );

Before doing nothig re-read the docs as it has been changed...

Say me if that helps....

对你而言 2024-12-11 18:02:27

我不确定我完全理解你的问题。以下几点可能会有所帮助:

  1. StageWebView 不理解 AIR 中其他位置使用的 app:/ 或 app-storage:/ 协议。因此,如果使用本地视频文件,请确保您使用的 URL file:/。我对 iOS 不太熟悉,但如果您无法访问应用程序存储或应用程序中的文件(假设您正在尝试这样做),您可以将它们复制到 File.userDirectory (在 Android 上是 SD应用程序启动时发生卡)。

  2. 也许您不需要完整的 StageWebViewBridge?我已经编写了如何使用 StageWebView 进行 AS 到 JS 通信(反之亦然)的基础知识 在我的博客上。 听起来像是为了你的需要,你只需要 AS -> JS,这只是意味着执行 swv.loadURL("javascript:somefunction('videoURL')")。其中 somefunction 设置 HTML5 标记的 src 参数。

I'm not sure I totally understand your question. A few things that may help:

  1. StageWebView does not understand the app:/ or app-storage:/ protocols that are used elsewhere in AIR. So make sure the URLs you are using file:/ if using a local video file. I'm not as familiar with iOS, but if you can't access files in app-storage or app (assuming you're trying to do that) you can possibly copy them over to File.userDirectory (which on Android is the SD card) on app startup.

  2. Perhaps you don't need the full StageWebViewBridge? I've written up the basics of how to do AS to JS communication (and vice-versa) with StageWebView on my blog. It sounds like for your needs, you only need AS -> JS, which simply means doing a swv.loadURL("javascript:somefunction('videoURL')"). Where somefunction sets the src parameter of your HTML5 tag.

墨洒年华 2024-12-11 18:02:27

为了更轻松地在您的 Air 应用程序和 JavaScript 之间进行通信,您可以尝试我们构建的 ANE https://github.com /myflashlab/webView-ANE

For easier communication between your Air app and JavaScript, you may try this ANE we have built https://github.com/myflashlab/webView-ANE

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文