async Task read(int index) { danmaku.ClearDanmu(); media.Visibility = Visibility.Collapsed; grid_status.Visibility = Visibility.Visible; cid = infos[index].Cid; aid = infos[0].Title; status.Text = "获取视频地址..."; URL = await ContentServ.GetVedioURL(cid, quality, format); status.Text += (URL == null) ? "失败" : $"{URL.Ps.Count}个{format}分段"; if (URL == null) { return; } status.Text += Environment.NewLine + "加载弹幕数据..."; try { DanmuPool = await GetDanmu(cid); } catch (Exception e) { status.Text += "失败" + e.Message; } if (format == VideoFormat.mp4) { // MP4只有一个分段(根据经验( ̄▽ ̄)") media.Source = new Uri(URL.Ps[0].Url); } else if (format == VideoFormat.flv) { // 先读第一个分段 SetFFmpegSource(URL.Ps[0].Url); } if (URL.Ps.Count > 1) { // Flag该立的时候也得立啊 // GetFlags(); } _currentP = URL.Ps[0]; txt_title.Text = infos[index].Title; if (URL.Acceptquality.Contains("1")) { q1.Visibility = Visibility.Visible; } if (URL.Acceptquality.Contains("2")) { q2.Visibility = Visibility.Visible; } if (URL.Acceptquality.Contains("3")) { q3.Visibility = Visibility.Visible; } status.Text += Environment.NewLine + "正在缓冲视频..."; loading.Visibility = Visibility.Visible; }
private FileSystemDirectory CreateDirectory(Purl path, FileAndDirectoryRules rules) { FileSystemDirectory entry = new FileSystemDirectory(path); foreach (string subPath in _fileSystem.GetEntries(path.AsString)) { Purl entryPath = new Purl(subPath); FileSystemEntry subEntry = FindEntry(entryPath, rules); if (subEntry != null) { entry.Entries.Add(subEntry); } } return entry; }
public FileSystemEntry FindEntry(Purl path, FileAndDirectoryRules rules) { if (_fileSystem.IsFile(path.AsString)) { if (rules.IncludesFile(path) != IncludeExclude.Exclude) { return CreateFile(path); } } else if (_fileSystem.IsDirectory(path.AsString)) { if (rules.IncludesDirectory(path) != IncludeExclude.Exclude) { return CreateDirectory(path, rules); } } return null; }
/// <summary> /// 设置FFmpeg媒体源 /// </summary> private void SetFFmpegSource(string url) { FFmpegMSS = FFmpegInteropMSS.CreateFFmpegInteropMSSFromUri(url, force_a, force_v); MediaStreamSource mss = FFmpegMSS.GetMediaStreamSource(); if (mss != null) { media.SetMediaStreamSource(mss); } // 更新当前分段 int index = URL.Ps.FindIndex(p => p.Url == url); _currentP = URL.Ps[index]; ///更新时间偏移量,用于<see cref="Timer_danmaku_Tick(object, object)"/> _offsettime = 0; for (int i = index; i > 0; i--) { _offsettime += (int)(URL.Ps[i - 1].Length / 1000); } }
public static FileSystemFile CreateFile(Purl path) { FileProperties properties = Infrastructure.FileSystem.GetFileProperties(path.AsString); return new FileSystemFile(path, properties.Length, properties.CreationTime, properties.LastAccessTime, properties.LastWriteTime); }
private static FileSystemFile CreateFile(Purl path) { return FileSystemFileFactory.CreateFile(path); }
public FileSystemEntry FindEntry(Purl path) { return FindEntry(path, _fileAndDirectoryRulesRepository.FindDefault()); }