2017-03-13 48 views
0

如何將VideoView實現到我的Xamarin.Forms共享代碼類中?Xamarin.Forms實現VideoView

我試了一下:

using Xamarin.Forms; 
using Xamarin.Forms.Xaml; 
using XamNative.ViewModels; 
using XamNative.Droid; 


[XamlCompilation(XamlCompilationOptions.Compile)] 
public partial class VideoPage : ContentPage 
{ 
    public VideoPage() 
    { 
     InitializeComponent(); 

#if __ANDROID__ 
    var linearLayout = new LinearLayout(Forms.Context); 
    linearLayout.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent); 

    var _videoView = new VideoView(linearLayout.Context) { }; 
    _videoView.SetMinimumHeight(300); 
    _videoView.SetMinimumWidth(300); 
    linearLayout.AddView(_videoView); 

//MediaRecorder Code... 
#endif 

}

我認爲它有一些東西到與VideoPage類從ContentPage,這是不正確的繼承繼承。

錯誤記錄爲「應用程序丟失表面」。

我可以實現一個TextView這種方式,但不是VideoView

回答