MvvmCross vnext : monodroid use a VideoView inside a plugin

让人想犯罪 __ 提交于 2019-12-13 02:35:51

问题


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

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

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).

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

Thanks in advance for your help.


回答1:


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?"

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

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

  • some control commands (things like start/stop)
  • some summary information - e.g. video length
  • a file access layer - this may be as little as a file path?

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!


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!

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.


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.



来源:https://stackoverflow.com/questions/13016103/mvvmcross-vnext-monodroid-use-a-videoview-inside-a-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!