Ejemplo n.º 1
0
        private async Task LoadVideo()
        {
            var url           = "https://www.w3schools.com/html/mov_bbb.mp4";
            var localFilename = "bunny.mp4";

            var fileSystem = DependencyService.Get <IFileSystem>();

            if (fileSystem.FileExists(localFilename) == false)
            {
                var api = Resolver.Resolve <IApi>();

                await api.DownloadAndSaveFile(url, localFilename);
            }

            var localFilePath = fileSystem.GetFilePath(localFilename);
            var videoView     = new ManneVideoView()
            {
                Url = localFilePath
            };

            AbsoluteLayout.SetLayoutFlags(videoView, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(videoView, new Rectangle(0f, 0f, 1f, 1f));

            _parentContainer.Children.Add(videoView);
        }
Ejemplo n.º 2
0
        // ----------------------------------------------

        #region Overrides

        protected override void OnElementChanged(ElementChangedEventArgs <View> e)
        {
            base.OnElementChanged(e);

            // Check if we have a control
            if (e.NewElement == null)
            {
                return;
            }

            // Get the forms view
            _view = (ManneVideoView)e.NewElement;

            // Create the movie player controller
            _controller = new MPMoviePlayerController();

            // Create the native view
            SetNativeControl(_controller.View);

            // Try to play
            LoadAndPlay();
        }
Ejemplo n.º 3
0
        public RecordAndPlayVideoPage()
        {
            // Create Container
            _parentContainer = new AbsoluteLayout
            {
                BackgroundColor   = Color.White,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            // Create Button
            _button = new Button
            {
                Text = "Record!"
            };

            AbsoluteLayout.SetLayoutFlags(_button, AbsoluteLayoutFlags.PositionProportional);
            AbsoluteLayout.SetLayoutBounds(_button, new Rectangle(0.5f, 0.5f, 100f, AbsoluteLayout.AutoSize));

            _button.Clicked += async(sender, e) =>
            {
                await RecordVideo();
            };

            _parentContainer.Children.Add(_button);

            // Create Video View
            _videoView = new ManneVideoView {
                IsVisible = false
            };

            AbsoluteLayout.SetLayoutFlags(_videoView, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(_videoView, new Rectangle(0f, 0f, 1f, 1f));

            _parentContainer.Children.Add(_videoView);

            // Finish
            Content = _parentContainer;
        }