Create the Platform-specific Service and execute the following code.
public void PlayVideoFromLocalStorage(string filePath) { try { var videoFile = new Java.IO.File(Java.Net.URI.Create($"file://{filePath}")); Android.Net.Uri fileUri = FileProvider.GetUriForFile(Android.App.Application.Context, $"{Android.App.Application.Context.PackageName}.fileprovider", videoFile); Intent intent = new Intent(); intent.SetAction(Intent.ActionView); intent.AddFlags(ActivityFlags.NewTask); intent.AddFlags(ActivityFlags.GrantReadUriPermission); intent.SetDataAndType(fileUri, "video/*"); Android.App.Application.Context.ApplicationContext.StartActivity(intent); } catch(Exception ex) { } }
No comments:
Post a Comment