I just want to record a video, copy it to local storage and be able to replay it. I have tried numerous different solutions. It works fine when debugging on an actual device from VS but as soon as the app is transferred to Apple I only get the red rectangle without content.
XAML:
<xct:MediaElement
BackgroundColor="red"
x:Name="mediaElement"
Source="{Binding Video}"
ShowsPlaybackControls="True"
HeightRequest="400"
HorizontalOptions="Fill"/>
MVVM:
public async void MoveVideo(FileResult fileResult)
{
var documentsFolder = GetVideoFolderPath();
var newFile = Path.Combine(documentsFolder, fileResult.FileName);
using (var stream = await fileResult.OpenReadAsync())
using (var newStream = File.OpenWrite(newFile))
await stream.CopyToAsync(newStream);
var ex = System.IO.File.Exists(Path.Combine(documentsFolder, fileResult.FileName)); // just to validate - returns true
}
public string GetVideoFolderPath()
{
var documentsFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
return documentsFolder;
}
private void CheckVideo() {
var documentsFolder = _videoService.GetVideoFolderPath();
var pathAndFile = Path.Combine(documentsFolder, LocalFilePath);
var b = new System.Uri(pathAndFile).AbsolutePath;
if(File.Exists(pathAndFile))
{
Video = MediaSource.FromFile(b);
}
}
Please note that it works and shows the video when debugging from VS. How can I ensure the playback?
Thanks!