.net core 2.2的进度条

时间:2019-06-24 22:30:16

标签: c# .net .net-core

我试图在单击按钮后添加进度栏,然后将触发视频转换。我现在可以在调试控制台中查看具有代码的进度,但是无法弄清楚如何弹出一个新页面,然后显示转换进度。

任何帮助将不胜感激!

public async Task<IActionResult> ConvertMedia(int? id, string mediaType)
        {
            FFmpeg.ExecutablesPath = "wwwroot/ffmpeg/";
            if (id != null)
            {
                switch (mediaType)
                {
                    case "Movies":
                        Movie movie = _context.Movie.Find(id);
                        string output = Path.Combine(movie.LocalPath + FileExtensions.Mp4);

                        IMediaInfo mediaInfo = await MediaInfo.Get(movie.LocalPath);

                        IStream videoStream = mediaInfo.VideoStreams.FirstOrDefault()
                            ?.SetCodec(VideoCodec.H264_nvenc)
                            ?.SetSize(VideoSize.Hd1080);
                        IStream audioStream = mediaInfo.AudioStreams.FirstOrDefault()
                            ?.SetCodec(AudioCodec.Aac);

                        IConversion conversion = Conversion.New().AddStream(videoStream, audioStream)
                            .SetOutput(output);


                         conversion.OnProgress += (sender, args) =>
                        {
                            var percent = (int)(Math.Round(args.Duration.TotalSeconds / args.TotalLength.TotalSeconds, 2) * 100);                         
                            Debug.WriteLine($"[{args.Duration} / {args.TotalLength}] {percent}%");
                        };
                        await conversion.Start();                        
                        //new movie file path here

                        break;

                        default:
                        return NotFound();
                } 

0 个答案:

没有答案