Last active
November 21, 2019 02:10
-
-
Save icebeam7/85ddc4a30b21af591022e12d088f09d5 to your computer and use it in GitHub Desktop.
DemoCamara: VideoViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Windows.Input; | |
using System.Threading.Tasks; | |
using Xamarin.Forms; | |
using DemoCamara.Services; | |
namespace DemoCamara.ViewModels | |
{ | |
public class VideoViewModel : BaseViewModel | |
{ | |
CameraService cameraService; | |
private string _videoURL; | |
public string VideoURL | |
{ | |
get { return _videoURL; } | |
set { _videoURL = value; OnPropertyChanged(); } | |
} | |
public ICommand TakeVideoCommand { get; private set; } | |
public ICommand ChooseVideoCommand { get; private set; } | |
public VideoViewModel() | |
{ | |
cameraService = new CameraService(); | |
Task.Run(async () => await cameraService.Init()); | |
TakeVideoCommand = new Command(async () => await TakeVideo()); | |
ChooseVideoCommand = new Command(async () => await ChooseVideo()); | |
} | |
private async Task TakeVideo() | |
{ | |
var file = await cameraService.TakeVideo(); | |
if (file != null) | |
VideoURL = file.Path; | |
} | |
private async Task ChooseVideo() | |
{ | |
var file = await cameraService.ChooseVideo(); | |
if (file != null) | |
VideoURL = file.Path; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment