在播放过程中或播放结束时点击视频后的自定义操作 [英] Custom action after tapping a video during the playback or when the playback ends

查看:79
本文介绍了在播放过程中或播放结束时点击视频后的自定义操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的用例:我有一个图像,它是视频的预览。当用户点击预览时,视频应开始全屏播放(我想是另一种形式)。当视频结束或在播放过程中用户点按视频时,应显示以前的表格。这与该问题的用例相同: Codename One纵向锁定的应用程序中以横向显示的表单

My use case: I have an image that is the preview of a video. When the user tap the preview, the video should starts a fullscreen playback (I suppose in another Form). When the video ends or when the user tap the video during the playback, the previous Form should be shown. This is the same use case of the question: Codename One landscape oriented Form in a portrait locked app

我的问题: MediaPlayer 类似乎没有公开一种在按下视频或视频结束时执行自定义操作的方法,如本用例所要求的。 MediaPlayer 是一个对等组件,因此我不确定尝试将按钮用作领导组件是否可以在轻按后执行操作。知道吗?

My question: the MediaPlayer class doesn't seem to expose a method to perform a custom action when pressing the video or when the video ends, like requested by this use case. The MediaPlayer is a peer component, so I'm not sure if trying to use a button as a leader component can make sense to do an action after a tap. Any idea?

推荐答案

不幸的是,从这个意义上讲,媒体非常复杂。您可以本地依赖媒体播放器的行为,该行为无缝地处理方向更改,播放等(搜索等)。或者,您也可以在媒体对象中自行实现所有操作,在这种情况下,您可以使用本机对等覆盖,并在媒体视图顶部有一个透明组件,它将捕获所有点击。

Unfortunately media is pretty complicated in that sense. You can either rely on the behavior of the media player natively which handles orientation change, playback etc. seamlessly (seek etc.). Or you can implement everything on your own in a media object in which case you can use native peer overlay and have a transparent component on top of the media view which will grab all the clicks.

前者将提供更原生的UX,并将自动旋转用户界面,但由于用户界面中没有 Form ,因此我们无法控制。调用 setNativePlayerMode(true)时会显示该信息。在这种情况下,当您点击视频时,它会暂停。要退出播放,您可以使用设备的本机键,例如返回或完成按钮,将返回到父表格。请注意,由于这是一种自然行为,因此在设备上的行为有所不同,因此在此处进行设备测试很重要。

The former will provide a more native UX and will auto-rotate the UI but we don't have control since there's no Form underlying the UI. It's shown when you invoke setNativePlayerMode(true). When you tap the video in this case it pauses. To exit playback you would use device native keys e.g. back or a done button and would be returned to the parent Form. Notice that since this is native behavior it acts differently on the device and it's important to do device testing here.

您的替代方法是将媒体组件放置在设备的中央。屏幕,然后您可以覆盖所有内容并自定义所有内容。您可以在顶部放置分层布局,并获取所有点击事件。您将需要添加自己的进度,播放,暂停等UI元素。用户需要物理旋转设备,因为方向不会自行改变(大部分情况下)。

Your alternative is to place a media component in the center of the screen and then you can override everything and customize everything. You can place a layered layout on top and grab all tap events. You will need to add your own progress, play, pause etc. UI elements. The user would need to physically rotate the device as orientation won't switch on its own (for the most part).

这篇关于在播放过程中或播放结束时点击视频后的自定义操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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