如何向 Flash Player 10.1 发出启动 flv 或 swf 的意图?
我在媒体服务器上存储了一堆flv视频文件,我试图让它们在Flash播放器中启动。一直在四处寻找但没有找到太多帮助。我已将 flv 文件下载到临时存储中,并尝试使用 intent
传递它。这就是我的代码的样子(来自我在网上看到的):
try{
URL urlLink = new URL("http://206.188.19.131/p4p101.flv");
// Serve the file
InputStream in = urlLink.openStream();
FileOutputStream fos = new FileOutputStream("/sdcard/tempFlash.flv");
byte[] buf = new byte[4 * 1024]; // 4K buffer
int bytesRead;
while ((bytesRead = in.read(buf)) != -1) {
fos.write(buf, 0, bytesRead);
}
fos.close();
in.close();
}
catch(Exception e){}
try{
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
File file = new File("/sdcard/tempFlash.flv");
intent.setDataAndType(Uri.fromFile(file), "flash/*");
startActivity(intent);
}
catch (ActivityNotFoundException e) {
Toast toast = Toast.makeText(this, "No apps to launch activity", 1000);
toast.show();
}
I have a bunch of flv video files stored on a media server, and I am trying to get them to launch in the flash player. Have been looking around but haven't found much help. I have downloaded the flv file into temporary storage, and try passing it using an intent
. This is what my code looks like (from what I have seen on the net):
try{
URL urlLink = new URL("http://206.188.19.131/p4p101.flv");
// Serve the file
InputStream in = urlLink.openStream();
FileOutputStream fos = new FileOutputStream("/sdcard/tempFlash.flv");
byte[] buf = new byte[4 * 1024]; // 4K buffer
int bytesRead;
while ((bytesRead = in.read(buf)) != -1) {
fos.write(buf, 0, bytesRead);
}
fos.close();
in.close();
}
catch(Exception e){}
try{
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
File file = new File("/sdcard/tempFlash.flv");
intent.setDataAndType(Uri.fromFile(file), "flash/*");
startActivity(intent);
}
catch (ActivityNotFoundException e) {
Toast toast = Toast.makeText(this, "No apps to launch activity", 1000);
toast.show();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许这可以帮助:
http://www.synesthesia.it/playing-flash-flv -android 应用程序中的视频
在 Android 上使用 webview 中的 flash 播放器播放 FLV
maybe this can help:
http://www.synesthesia.it/playing-flash-flv-videos-in-android-applications
playing FLV on Android using flash player inside a webview
可能会尝试更改您的 mimetype:
视频/x-flv 或 flv-application/octet-stream
may be try to change your mimetype:
video/x-flv or flv-application/octet-stream