Skip to content

Instantly share code, notes, and snippets.

@icebeam7
Last active November 21, 2019 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icebeam7/85ddc4a30b21af591022e12d088f09d5 to your computer and use it in GitHub Desktop.
Save icebeam7/85ddc4a30b21af591022e12d088f09d5 to your computer and use it in GitHub Desktop.
DemoCamara: VideoViewModel.cs
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