本文介绍了MvvmCross vnext:Monodroid在插件内使用VideoView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当时在玩Xamarin Mobile api MediaPicker,后者使用MediaRecorder和monodroid制作了一个插件来录制视频.

I was playing with Xamarin Mobile api MediaPicker which uses MediaRecorder with monodroid to make a plugin to record a video.

Android必须在VideoView中预览视频.出于隐私目的,此限制也适用于wp7和ios.

Android must preview the video inside a VideoView. This restriction applies to wp7 and ios too for privacy.

因此,我需要从自定义视图中获取VideoView(或wp7中的Rectangle),并将setPreviewDisplay设置为插件中的此VideoView(或使用此VideoView初始化MediaPicker).

So, I need to get the VideoView (or Rectangle in wp7) from my custom view and setPreviewDisplay to this VideoView in my plugin (or init MediaPicker with this VideoView).

实现需要UI元素的可移植插件的最佳方法是什么?

What is the best way to implement my portable plugin which requires UI element ?

预先感谢您的帮助.

推荐答案

我想我的第一个问题是您需要便携式插件吗?"

I guess my first question is "do you need a portable plugin?"

在ViewModel层或更低的层上实际需要的接口是什么?

What is the interface that you actually need at the ViewModel layer or lower?

我的猜测是,ViewModel将看到的跨平台接口可能只包含:

My guess is that the cross-platform interface that the ViewModel will see might contain just:

  • 一些控制命令(例如开始/停止之类的东西)
  • 一些摘要信息-例如视频长度
  • 文件访问层-这可能与文件路径一样小?

如果是这种情况,那么我可能会在UI中的Controls/Views/UIViews中实现大多数逻辑,然后将相关的命令和值绑定到那些ViewModel属性.

If that's the case, then I'd probably implement most of the logic within Controls/Views/UIViews in the UIs, and would then bind the relevant commands and values to those ViewModel properties.

所以我根本不会亲自将其实现为插件!

So I wouldn't personally implement this as a plugin at all!

我以前曾经做过一些使用视频视图的应用程序-一个用于视频捕获(仅适用于Android),另一个用于条形码扫描.

I've previously done a couple of apps which use video views - one for video capture (Android only), one for bar code scanning.

我发现基本的可用样本效果很好.但是,一旦我开始尝试扩展它们,它们很快就变得脆弱,难以工作,而且开发也很沮丧!

I found that the basic available samples worked quite well. However, once I started trying to extend them, then they became quickly fragile, they were hard to get working and they were quite frustrating to develop!

我真的建议您以UI View代码的形式开始当前的开发.在工作之后,您可能会找到一种将控件和界面拆分为插件的好方法-但我怀疑这不会花费您的大部分时间.

I would genuinely recommend starting your current develop as UI View code. After you've got it working, then you might find a nice way to split up the control and interface into a plugin - but I suspect that this won't be where most of your time is spent.

例如对于我的下一个QR代码应用程序,我计划在 https://github.com/Redth中使用单独的UI控件/ZxingSharp.Mobile -在ViewModel级别,我希望可以公开一些对解码后的QR字符串起作用的Command.

e.g. for my next QR code app, I plan to use the separate UI controls in https://github.com/Redth/ZxingSharp.Mobile - at the ViewModel level, I can hopefully just expose some sort of Command which acts on the decoded QR strings.

这篇关于MvvmCross vnext:Monodroid在插件内使用VideoView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 22:35