Exemple #1
0
        public async Task <bool> PlayFile(string file)
        {
            await SetSource($"file://{IO.AbsolutePath(file)}");

            Player.Start();

            return(await Ended.Task);
        }
Exemple #2
0
        void LoadVideo()
        {
            if (IsDead(out var view))
            {
                return;
            }

            var source = view.Path;

            if (source.IsEmpty())
            {
                return;
            }

            if (!IsSurfaceCreated)
            {
                VideoSurfaceCreate.Raise(VideoState.Play);
                return;
            }

            if (IO.IsAbsolute(source))
            {
                source = "file://" + source;
            }
            else if (!source.IsUrl())
            {
                source = "file://" + IO.AbsolutePath(source);
            }
            try
            {
                VideoPlayer.Reset();
                VideoPlayer.SetDataSource(Renderer.Context, Android.Net.Uri.Parse(source));

                if (source.IsUrl() || view.AutoBuffer)
                {
                    VideoPlayer.PrepareAsync();
                }
            }
            catch (Java.Lang.Exception ex)
            {
                Log.For(this).Error(ex, "This error is raised without seemingly affecting anything!");
            }
        }