Delphi android intent无法打开正确的应用程序进行视频播放或应用程序无法正常运行 [英] Delphi android intent does not open the right app for video playing or app does not behave properly

查看:301
本文介绍了Delphi android intent无法打开正确的应用程序进行视频播放或应用程序无法正常运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Delphi XE5用于为用户创建.avi视频文件的应用程序. 成功创建视频后(甚至只是因为用户想再次观看视频),它会尝试使用视频的首选应用程序将其打开. 我了解android为文件类型选择了正确的应用程序,或者您可以通过提供文件的MIME类型进行定向. 因此,我正在使用Delphi中的意图

I´m using Delphi XE5 for an app that creates an .avi video file for the user. After successfully creating it (or even just because the user wants to watch the video again) it tries to open it using the app of choice for videos. I understand that android picks the right app for the file type or you can direct it providing the MIME type of the file. So, using intents from Delphi I´m doing

intent:=TJIntent.Create;
intent.setAction(TJIntent.JavaClass.ACTION_VIEW);      
intent.setData(TJnet_Uri.JavaClass.parse(StringToJString('file://'videoFile)));
intent.setType(StringToJString('video/avi'));

执行此操作时,会出现一个非常基本的视频播放器(设置"的运行应用程序"部分显示一个名为Android Media的应用程序正在运行)带有播放按钮,但不显示视频. 但是,如果您使用任何文件管理器,甚至浏览图库,然后单击查看视频"应用程序,文件都能很好地播放.

When I do this, a very basic video player appears (the Running Apps section of Setting show an app called Android Media running) with a play button but does not show the video. But if you use any File Manager or even go through the Gallery and click on the file it plays nicely using the View Video app.

我无法让我的应用直接调用查看视频",甚至无法显示视频应用列表供用户选择. 我尝试了不同的MIME类型,例如

I can´t make my app call View Video directly, not even show a list of video apps for the user to choose it. I tried different MIME types like

intent.setType(StringToJString('video/*'));

甚至

intent.setType(StringToJString('*/*'));

这允许用户从设备中的任何应用中进行选择(无意义,仅用于测试),因此他可以选择查看视频",即使这样做,该应用仅显示播放按钮,而在按下时不显示任何内容.

Which lets the user choose from any app in its device (nosense but just for testing) so he can choose View Video but even doing that the app shows only a play button and displays no content when pressed.

因此,从我的应用程序调用时,查看视频"似乎无法播放我创建的视频(我没有打开它或进行类似检查),但是从其他应用程序调用时,它可以播放.

So, it looks like when called from my app, View Video can´t play the video I created (I do not have it opened or something like that, checked) but when called from other apps it can.

使用Delphi XE5的意图时,有人知道错误或局限性吗?或者我做错了吗?

Does anybody know of bugs or limitations when using intents from Delphi XE5 or maybe I´m not doing it right?

推荐答案

intent.settype破坏了data属性的内容. 使用另一个SetDataAndType这样的setter效果很好.用那个! 不知道他们是否在XE6或XE7中对其进行了修复.

intent.settype in Delphi XE5 was ruining the contents of the data property. Using another setter like SetDataAndType works well. Use that one! Not sure if they fixed it in XE6 or XE7.

这篇关于Delphi android intent无法打开正确的应用程序进行视频播放或应用程序无法正常运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆