﻿using System.IO;
using System.Threading.Tasks;
using Android.App;
using Buftaku_Subtitle_Utility.Helpers;

namespace Buftaku_Subtitle_Utility.Subtitle.Writer
{
    public class VttWriter : ISubtitlesWriter
    {
        public async Task Write(SubtitleData data, string path)
        {
            var assWriter = new AssWriter();
            var tempPath = Path.Combine(AndroidHelper.DataDir, Path.GetFileNameWithoutExtension(path) + ".vtt");
            await assWriter.Write(data, tempPath);
            await FFMpeg.Core.Library.Run($"-y -i {tempPath} {path}");
            await Task.Delay(500);
        }
    }
}