Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
7c3f834786
commit
54c595809e
13
CdgPlayer/KaraokeVideoPlayer.Designer.cs
generated
13
CdgPlayer/KaraokeVideoPlayer.Designer.cs
generated
@ -2,6 +2,7 @@
|
||||
{
|
||||
partial class KaraokeVideoPlayer
|
||||
{
|
||||
public bool isCDG { get; set; }
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
@ -43,12 +44,12 @@
|
||||
this.vlcPlayer.TabIndex = 0;
|
||||
this.vlcPlayer.Text = "vlcControl1";
|
||||
this.vlcPlayer.VlcLibDirectory = null;
|
||||
this.vlcPlayer.VlcMediaplayerOptions = new string[] {
|
||||
"--projectm-preset-path=lib\\presets",
|
||||
"--audio-visual=projectm",
|
||||
"--effect-list=scope",
|
||||
"--no-video",
|
||||
"--verbose=2"};
|
||||
if (isCDG) {
|
||||
this.vlcPlayer.VlcMediaplayerOptions = new string[] { "--projectm-preset-path=lib\\presets", "--audio-visual=projectm", "--effect-list=scope", "--no-video", "--verbose=2" };
|
||||
}
|
||||
else {
|
||||
this.vlcPlayer.VlcMediaplayerOptions = new string[] { "--projectm-preset-path=lib\\presets", "--effect-list=scope", "--verbose=2" };
|
||||
}
|
||||
this.vlcPlayer.VlcLibDirectoryNeeded += new System.EventHandler<Vlc.DotNet.Forms.VlcLibDirectoryNeededEventArgs>(this.vlcPlayer_VlcLibDirectoryNeeded);
|
||||
this.vlcPlayer.Playing += new System.EventHandler<Vlc.DotNet.Core.VlcMediaPlayerPlayingEventArgs>(this.vlcPlayer_Playing);
|
||||
this.vlcPlayer.TimeChanged += new System.EventHandler<Vlc.DotNet.Core.VlcMediaPlayerTimeChangedEventArgs>(this.vlcPlayer_TimeChanged);
|
||||
|
||||
@ -29,14 +29,20 @@ namespace KaraokePlayer
|
||||
|
||||
private void LyricTimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
|
||||
{
|
||||
var picture = _cdgFile.RenderAtTime((long)(DateTime.Now - _startTime).TotalMilliseconds);
|
||||
BeginInvoke(new MethodInvoker(() => { _overlayForm.Graphic.Image = picture; }));
|
||||
if (isCDG)
|
||||
{
|
||||
var picture = _cdgFile.RenderAtTime((long)(DateTime.Now - _startTime).TotalMilliseconds);
|
||||
BeginInvoke(new MethodInvoker(() => { _overlayForm.Graphic.Image = picture; }));
|
||||
}
|
||||
}
|
||||
|
||||
public async void Play(Uri file)
|
||||
{
|
||||
vlcPlayer.SetMedia(file);
|
||||
_cdgFile = await GraphicsFile.LoadAsync(Path.ChangeExtension(file.LocalPath, "cdg"));
|
||||
if (isCDG)
|
||||
{
|
||||
_cdgFile = await GraphicsFile.LoadAsync(Path.ChangeExtension(file.LocalPath, "cdg"));
|
||||
}
|
||||
vlcPlayer.Play();
|
||||
}
|
||||
|
||||
|
||||
65
KaraokePlayer/MainForm.Designer.cs
generated
65
KaraokePlayer/MainForm.Designer.cs
generated
@ -33,11 +33,12 @@
|
||||
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||
this.browseDialog = new System.Windows.Forms.FolderBrowserDialog();
|
||||
this.karaokeVideoPlayer1 = new KaraokePlayer.KaraokeVideoPlayer();
|
||||
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.materialListBox1 = new MaterialSkin.Controls.MaterialListBox();
|
||||
this.materialSingleLineTextField1 = new MaterialSkin.Controls.MaterialSingleLineTextField();
|
||||
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.karaokeCDGPlayer = new KaraokePlayer.KaraokeVideoPlayer();
|
||||
this.karaokeMP4Player = new KaraokePlayer.KaraokeVideoPlayer();
|
||||
this.browseDialog = new System.Windows.Forms.FolderBrowserDialog();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
this.flowLayoutPanel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||
@ -117,22 +118,27 @@
|
||||
//
|
||||
// splitContainer1.Panel2
|
||||
//
|
||||
this.splitContainer1.Panel2.Controls.Add(this.karaokeVideoPlayer1);
|
||||
this.splitContainer1.Panel2.Controls.Add(this.karaokeCDGPlayer);
|
||||
this.splitContainer1.Panel2.Controls.Add(this.karaokeMP4Player);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(713, 458);
|
||||
this.splitContainer1.SplitterDistance = 237;
|
||||
this.splitContainer1.TabIndex = 6;
|
||||
//
|
||||
// browseDialog
|
||||
// tableLayoutPanel2
|
||||
//
|
||||
this.browseDialog.SelectedPath = "D:\\Karaoke\\SF360 February 2016\\SF360-01 - Charlie Puth - One Call Away\\";
|
||||
//
|
||||
// karaokeVideoPlayer1
|
||||
//
|
||||
this.karaokeVideoPlayer1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.karaokeVideoPlayer1.Location = new System.Drawing.Point(0, 0);
|
||||
this.karaokeVideoPlayer1.Name = "karaokeVideoPlayer1";
|
||||
this.karaokeVideoPlayer1.Size = new System.Drawing.Size(472, 458);
|
||||
this.karaokeVideoPlayer1.TabIndex = 0;
|
||||
this.tableLayoutPanel2.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.tableLayoutPanel2.ColumnCount = 1;
|
||||
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tableLayoutPanel2.Controls.Add(this.materialListBox1, 0, 1);
|
||||
this.tableLayoutPanel2.Controls.Add(this.materialSingleLineTextField1, 0, 0);
|
||||
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel2.Location = new System.Drawing.Point(0, 0);
|
||||
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
|
||||
this.tableLayoutPanel2.RowCount = 2;
|
||||
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel2.Size = new System.Drawing.Size(237, 458);
|
||||
this.tableLayoutPanel2.TabIndex = 7;
|
||||
//
|
||||
// materialListBox1
|
||||
//
|
||||
@ -175,21 +181,21 @@
|
||||
this.materialSingleLineTextField1.UseSystemPasswordChar = false;
|
||||
this.materialSingleLineTextField1.TextChanged += new System.EventHandler(this.materialSingleLineTextField1_TextChanged);
|
||||
//
|
||||
// tableLayoutPanel2
|
||||
// karaokeCDGPlayer
|
||||
//
|
||||
this.tableLayoutPanel2.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.tableLayoutPanel2.ColumnCount = 1;
|
||||
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tableLayoutPanel2.Controls.Add(this.materialListBox1, 0, 1);
|
||||
this.tableLayoutPanel2.Controls.Add(this.materialSingleLineTextField1, 0, 0);
|
||||
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel2.Location = new System.Drawing.Point(0, 0);
|
||||
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
|
||||
this.tableLayoutPanel2.RowCount = 2;
|
||||
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel2.Size = new System.Drawing.Size(237, 458);
|
||||
this.tableLayoutPanel2.TabIndex = 7;
|
||||
this.karaokeCDGPlayer.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.karaokeCDGPlayer.Location = new System.Drawing.Point(0, 0);
|
||||
this.karaokeCDGPlayer.Name = "karaokeCDGPlayer";
|
||||
this.karaokeCDGPlayer.Size = new System.Drawing.Size(472, 458);
|
||||
this.karaokeCDGPlayer.TabIndex = 0;
|
||||
this.karaokeCDGPlayer.isCDG = true;
|
||||
|
||||
this.karaokeMP4Player.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.karaokeMP4Player.Location = new System.Drawing.Point(0, 0);
|
||||
this.karaokeMP4Player.Name = "karaokeMP4Player";
|
||||
this.karaokeMP4Player.Size = new System.Drawing.Size(472, 458);
|
||||
this.karaokeMP4Player.TabIndex = 0;
|
||||
this.karaokeMP4Player.isCDG = false;
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
@ -218,7 +224,8 @@
|
||||
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
|
||||
private System.Windows.Forms.FolderBrowserDialog browseDialog;
|
||||
private System.Windows.Forms.SplitContainer splitContainer1;
|
||||
private KaraokeVideoPlayer karaokeVideoPlayer1;
|
||||
private KaraokeVideoPlayer karaokeCDGPlayer;
|
||||
private KaraokeVideoPlayer karaokeMP4Player;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
|
||||
private MaterialSkin.Controls.MaterialListBox materialListBox1;
|
||||
private MaterialSkin.Controls.MaterialSingleLineTextField materialSingleLineTextField1;
|
||||
|
||||
@ -25,16 +25,16 @@ namespace KaraokePlayer
|
||||
|
||||
private void materialRaisedButton1_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
karaokeVideoPlayer1.Play(new Uri(@"D:\Karaoke\SF360 February 2016\SF360-01 - Charlie Puth - One Call Away\SF360-01 - Charlie Puth - One Call Away.mp3"));
|
||||
playSelectedFile();
|
||||
}
|
||||
|
||||
private void btnBrowse_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (browseDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
|
||||
var files = System.IO.Directory.GetFiles(browseDialog.SelectedPath, "*.cdg", searchOption: System.IO.SearchOption.AllDirectories);
|
||||
_fileList = files.Select(file => new FileInfo(file)).ToList();
|
||||
var files = GetFiles(browseDialog.SelectedPath, "*.cdg|*.mp4", searchOption: System.IO.SearchOption.AllDirectories);
|
||||
var filtered = files.Where(f => f.Length < 248).ToList();
|
||||
_fileList = filtered.Select(file => new FileInfo(file)).ToList();
|
||||
materialListBox1.DataSource = _fileList;
|
||||
materialListBox1.DisplayMember = "Name";
|
||||
|
||||
@ -46,7 +46,7 @@ namespace KaraokePlayer
|
||||
int index = this.materialListBox1.IndexFromPoint(e.Location);
|
||||
if (index != System.Windows.Forms.ListBox.NoMatches)
|
||||
{
|
||||
karaokeVideoPlayer1.Play(new Uri(Path.ChangeExtension(((FileInfo)materialListBox1.Items[index]).FullName,".mp3")));
|
||||
playSelectedFile();
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,5 +55,33 @@ namespace KaraokePlayer
|
||||
materialListBox1.DataSource = _fileList.Where(
|
||||
file => Regex.IsMatch(file.Name, materialSingleLineTextField1.Text, RegexOptions.IgnoreCase)).ToList();
|
||||
}
|
||||
|
||||
public static string[] GetFiles(string path, string searchPattern, SearchOption searchOption)
|
||||
{
|
||||
string[] searchPatterns = searchPattern.Split('|');
|
||||
List<string> files = new List<string>();
|
||||
foreach (string sp in searchPatterns)
|
||||
files.AddRange(System.IO.Directory.GetFiles(path, sp, searchOption));
|
||||
files.Sort();
|
||||
return files.ToArray();
|
||||
}
|
||||
|
||||
public void playSelectedFile()
|
||||
{
|
||||
FileInfo file = (FileInfo)materialListBox1.SelectedItem;
|
||||
if (file.Extension.ToLower() == ".cdg")
|
||||
{
|
||||
karaokeCDGPlayer.Play(new Uri(Path.ChangeExtension(file.FullName, ".mp3")));
|
||||
karaokeCDGPlayer.Visible = true;
|
||||
karaokeMP4Player.Visible = false;
|
||||
}
|
||||
else {
|
||||
karaokeMP4Player.Play(new Uri(file.FullName));
|
||||
karaokeMP4Player.Visible = true;
|
||||
karaokeCDGPlayer.Visible = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user