/// <summary> /// 使用外部播放器播放 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dropDownButton1_Click(object sender, EventArgs e) { VideoPath path = AppSettings.VideoPlayPath.FirstOrDefault(t => t.Name == dropDownButton1.Text); if (path != null) { if (!File.Exists(path.Path)) { MessageBox.Show("没有指定播放器"); return; } process = Process.Start(path.Path, AppSettings.ReturnStringUrl(Methods.ConversionString(videoplay.Uri))); return; } else { if (openFileDialog1.ShowDialog() == DialogResult.OK) { VideoPath videoPath = new VideoPath() { Name = dropDownButton1.Text }; videoPath.Path = openFileDialog1.FileName; process = Process.Start(videoPath.Path, AppSettings.ReturnStringUrl(Methods.ConversionString(videoplay.Uri))); Program.log.Info("使用关联播放器播放", new Exception($"Program.VideoPlay")); AppSettings.VideoPlayPath.Add(videoPath); Methods.WritePath(AppSettings.PlayerPath, AppSettings.VideoPlayPath); } } }
/// <summary> /// 重置外部播放器路径 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DeletePToolStripMenuItem_Click(object sender, EventArgs e) { VideoPath path = AppSettings.VideoPlayPath.FirstOrDefault(t => t.Name == dropDownButton1.Text); if (path != null) { AppSettings.VideoPlayPath.Remove(path); } Methods.WritePath(AppSettings.PlayerPath, AppSettings.VideoPlayPath); }
/// <summary> /// 去水印事件 /// </summary> private async void ExecuteDelogoCommand() { if (isDelogo) { eventAggregator.GetEvent <MessageEvent>().Publish(DictionaryResource.GetString("TipWaitTaskFinished")); return; } if (VideoPath == "") { eventAggregator.GetEvent <MessageEvent>().Publish(DictionaryResource.GetString("TipNoSeletedVideo")); return; } if (LogoWidth == -1) { eventAggregator.GetEvent <MessageEvent>().Publish(DictionaryResource.GetString("TipInputRightLogoWidth")); return; } if (LogoHeight == -1) { eventAggregator.GetEvent <MessageEvent>().Publish(DictionaryResource.GetString("TipInputRightLogoHeight")); return; } if (LogoX == -1) { eventAggregator.GetEvent <MessageEvent>().Publish(DictionaryResource.GetString("TipInputRightLogoX")); return; } if (LogoY == -1) { eventAggregator.GetEvent <MessageEvent>().Publish(DictionaryResource.GetString("TipInputRightLogoY")); return; } // 新文件名 string newFileName = VideoPath.Insert(VideoPath.Length - 4, "_delogo"); Status = string.Empty; await Task.Run(() => { // 执行去水印程序 isDelogo = true; FFmpegHelper.Delogo(VideoPath, newFileName, LogoX, LogoY, LogoWidth, LogoHeight, new Action <string>((output) => { Status += output + "\n"; })); isDelogo = false; }); }
protected void OnButtonPlayClicked(object sender, System.EventArgs e) { if (_play != null) { _play.Stop(); } int handle = (int)this.drawingareaVideo.Handle; if (System.IO.File.Exists(VideoPath) == false && VideoPath.StartsWith("http") == false) { throw new System.IO.FileNotFoundException("File not found", VideoPath); } _play = new MPlayer(handle, MplayerBackends.GL, MPlayerPath); _play.Play(VideoPath); }
private void buttonPlay_Click(object sender, EventArgs e) { if (_play != null) { _play.Stop(); } int handle = (int)this.panelVideo.Handle; if (System.IO.File.Exists(MPlayerPath) == false) { throw new System.IO.FileNotFoundException("File not found", MPlayerPath); } if (System.IO.File.Exists(VideoPath) == false && VideoPath.StartsWith("http") == false) { throw new System.IO.FileNotFoundException("File not found", VideoPath); } _play = new MPlayer(handle, MplayerBackends.Direct3D, MPlayerPath); _play.Play(VideoPath); }
private void buttonPlay_Click(object sender, EventArgs e) { if (_play != null) { _play.Stop(); } if (System.IO.File.Exists(MPlayerPath) == false && _play is LibMPlayerCommon.MPlayer) { throw new System.IO.FileNotFoundException("File not found", MPlayerPath); } if (System.IO.File.Exists(VideoPath) == false && VideoPath.StartsWith("http") == false) { throw new System.IO.FileNotFoundException("File not found", VideoPath); } if (_play == null) { //_play = new MPlayer(Handle, MplayerBackends.Direct3D, MPlayerPath); } _play.Play(VideoPath); }
public static async Task UploadGitHub(string indexDirectory, string username, string password, string apiToken, string owner, string repository, string tag) { var workspace = Helpers.GetWorkspace(indexDirectory); if (string.IsNullOrEmpty(username)) { username = Environment.GetEnvironmentVariable("GITHUB_USERNAME"); } if (string.IsNullOrEmpty(password)) { password = Environment.GetEnvironmentVariable("GITHUB_PASSWORD"); } if (string.IsNullOrEmpty(apiToken)) { apiToken = Environment.GetEnvironmentVariable("GITHUB_API_TOKEN"); } if (string.IsNullOrEmpty(apiToken) && string.IsNullOrEmpty(username) && string.IsNullOrEmpty(password)) { Log.Error("You must provide a either an api token or username/password paid."); Environment.Exit(1); } if (string.IsNullOrEmpty(apiToken)) { if (string.IsNullOrEmpty(username)) { Log.Error("You must provide a user name."); Environment.Exit(1); } if (string.IsNullOrEmpty(password)) { Log.Error("You must provide a password."); Environment.Exit(1); } } var client = new GitHubClient(new ProductHeaderValue("youtube-archiver")); client.SetRequestTimeout(TimeSpan.FromMinutes(60)); if (!string.IsNullOrEmpty(apiToken)) { client.Credentials = new Credentials(apiToken); } else { client.Credentials = new Credentials(username, password); } var release = await client.Repository.Release.Get(owner, repository, tag); if (release == null) { Log.Error("The release doesn't exist."); Environment.Exit(1); } foreach (var video in workspace.GetVideos()) { var videoPath = workspace.GetVideoPath(video.Id); if (videoPath is VideoPathLocal videoPathLocal) { var asset = release.Assets.SingleOrDefault(x => x.Name == $"{video.Id}.mp4"); if (asset != null) { // It exists remotely, but we don't know about it locally. Log.Warning("The video {videoId} exists remotely, but local didn't know, updating local...", video.Id); workspace.UpdateVideoPath(video.Id, VideoPath.External(asset.BrowserDownloadUrl)); continue; } Log.Information("Uploading {video}...", video.Id); await using (var stream = File.OpenRead(videoPathLocal.Path)) { asset = await client.Repository.Release.UploadAsset(release, new ReleaseAssetUpload($"{video.Id}.mp4", "video/mp4", stream, TimeSpan.FromMinutes(60))); } Log.Information("Uploaded video, updating local index."); workspace.UpdateVideoPath(video.Id, VideoPath.External(asset.BrowserDownloadUrl)); } } Log.Information("Done!"); }
public string GetVideoName() { return(VideoPath.Split('\\').LastOrDefault()); }