2508191749
撥放器參數調整 媒體播畢邏輯判斷更改 系統公告顏色改回紅色
This commit is contained in:
parent
c634c8e27c
commit
7d71e85d57
@ -266,6 +266,7 @@ namespace OverlayFormObj
|
|||||||
using (Font largeFont = new Font("微軟正黑體", 34, FontStyle.Bold))
|
using (Font largeFont = new Font("微軟正黑體", 34, FontStyle.Bold))
|
||||||
using (Font secondLineFont = new Font("微軟正黑體", 34, FontStyle.Bold))
|
using (Font secondLineFont = new Font("微軟正黑體", 34, FontStyle.Bold))
|
||||||
using (Brush whiteBrush = new SolidBrush(Color.White))
|
using (Brush whiteBrush = new SolidBrush(Color.White))
|
||||||
|
using (Brush RedBrush = new SolidBrush(Color.Red))
|
||||||
using (Brush marqueeBrush = new SolidBrush(marqueeTextColor))
|
using (Brush marqueeBrush = new SolidBrush(marqueeTextColor))
|
||||||
using (Brush backgroundBrush = new SolidBrush(Color.FromArgb(255, 0, 0, 0)))
|
using (Brush backgroundBrush = new SolidBrush(Color.FromArgb(255, 0, 0, 0)))
|
||||||
{
|
{
|
||||||
@ -279,10 +280,10 @@ namespace OverlayFormObj
|
|||||||
float yPosition2 = 56;
|
float yPosition2 = 56;
|
||||||
Rectangle clipRect = new Rectangle(
|
Rectangle clipRect = new Rectangle(
|
||||||
// (int)(this.Width / 32), // 从1/8改成1/16(因为要居中)
|
// (int)(this.Width / 32), // 从1/8改成1/16(因为要居中)
|
||||||
(int)(this.Width*0.32),
|
(int)(this.Width * 0.32),
|
||||||
(int)yPosition2,
|
(int)yPosition2,
|
||||||
// (int)(15 * this.Width / 16), // 从3/4改成7/8
|
// (int)(15 * this.Width / 16), // 从3/4改成7/8
|
||||||
(int)(this.Width*0.56),
|
(int)(this.Width * 0.56),
|
||||||
(int)textSize.Height
|
(int)textSize.Height
|
||||||
);
|
);
|
||||||
Region originalClip = e.Graphics.Clip;
|
Region originalClip = e.Graphics.Clip;
|
||||||
@ -294,7 +295,7 @@ namespace OverlayFormObj
|
|||||||
e.Graphics.FillRectangle(backgroundBrush, centeredXPos, yPosition2, textSizeSecondLine.Width, textSizeSecondLine.Height);
|
e.Graphics.FillRectangle(backgroundBrush, centeredXPos, yPosition2, textSizeSecondLine.Width, textSizeSecondLine.Height);
|
||||||
// 系統公告塗色調整區域
|
// 系統公告塗色調整區域
|
||||||
// e.Graphics.DrawString(displayText, secondLineFont, RedBrush, new PointF(centeredXPos, yPosition2));
|
// e.Graphics.DrawString(displayText, secondLineFont, RedBrush, new PointF(centeredXPos, yPosition2));
|
||||||
e.Graphics.DrawString(displayText, secondLineFont, marqueeBrush, new PointF((int)(this.Width*0.32), yPosition2));
|
e.Graphics.DrawString(displayText, secondLineFont, RedBrush, new PointF((int)(this.Width * 0.32), yPosition2));
|
||||||
// 还原裁剪区域
|
// 还原裁剪区域
|
||||||
e.Graphics.Clip = originalClip;
|
e.Graphics.Clip = originalClip;
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@ namespace DualScreenDemo.Services
|
|||||||
{
|
{
|
||||||
public class MediaService : IDisposable
|
public class MediaService : IDisposable
|
||||||
{
|
{
|
||||||
private readonly LibVLC _libVLC;
|
private LibVLC _libVLC;
|
||||||
private readonly MediaPlayer _mediaPlayer;
|
private MediaPlayer _mediaPlayer;
|
||||||
private Media? _media;
|
private Media? _media;
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
@ -13,14 +13,14 @@ namespace DualScreenDemo.Services
|
|||||||
{
|
{
|
||||||
Core.Initialize();
|
Core.Initialize();
|
||||||
_libVLC = new LibVLC(
|
_libVLC = new LibVLC(
|
||||||
|
// "--verbose=2",
|
||||||
"--vout=automatic",
|
"--audio-time-stretch",
|
||||||
"--h264-fps=25",
|
// "--vout=automatic",
|
||||||
|
"--h264-fps=30",
|
||||||
"--aout=directsound",
|
"--aout=directsound",
|
||||||
"--network-caching=250",
|
"--network-caching=250",
|
||||||
"--file-caching=250",
|
"--file-caching=250",
|
||||||
"--audio-time-stretch"
|
"--audio-time-stretch"
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
_mediaPlayer = new MediaPlayer(_libVLC);
|
_mediaPlayer = new MediaPlayer(_libVLC);
|
||||||
@ -47,66 +47,56 @@ namespace DualScreenDemo.Services
|
|||||||
public MediaPlayer Player => _mediaPlayer;
|
public MediaPlayer Player => _mediaPlayer;
|
||||||
public bool IsPlaying => _mediaPlayer.IsPlaying;
|
public bool IsPlaying => _mediaPlayer.IsPlaying;
|
||||||
|
|
||||||
public bool IsAtEnd()
|
// public bool IsAtEnd()
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var duration = _mediaPlayer.Media?.Duration ?? 0;
|
|
||||||
var time = _mediaPlayer.Time;
|
|
||||||
return duration > 0 && Math.Abs(duration - time) < 1000;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine(ex.Message);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// public void LoadMedia(string filePath, int audioTrackIndex = 0)
|
|
||||||
// {
|
// {
|
||||||
// try
|
// try
|
||||||
// {
|
// {
|
||||||
// Console.WriteLine($"LoadMedia. in");
|
// _mediaPlayer.EndReached += (sender, args) => { };
|
||||||
// _media?.ParseStop();
|
|
||||||
// Console.WriteLine($"LoadMedia. ParseStop");
|
|
||||||
// _mediaPlayer.Stop();
|
|
||||||
// Console.WriteLine($"LoadMedia. Stop");
|
|
||||||
// _media?.Dispose();
|
|
||||||
// Console.WriteLine($"LoadMedia. Dispose");
|
|
||||||
|
|
||||||
// _media = new Media(_libVLC, filePath, FromType.FromPath);
|
|
||||||
// _media.AddOption(":audio-output=directsound");
|
|
||||||
// _media.AddOption($":audio-track={audioTrackIndex}");
|
|
||||||
// _mediaPlayer.Play(_media);
|
|
||||||
|
|
||||||
|
// var duration = _mediaPlayer.Media?.Duration ?? 0;
|
||||||
|
// var time = _mediaPlayer.Time;
|
||||||
|
// return duration > 0 && Math.Abs(duration - time) < 1000;
|
||||||
// }
|
// }
|
||||||
// catch (Exception ex)
|
// catch (Exception ex)
|
||||||
// {
|
// {
|
||||||
// Console.WriteLine(ex.Message);
|
// Console.WriteLine(ex.Message);
|
||||||
|
// return true;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
public bool IsAtEnd()
|
||||||
|
{
|
||||||
|
if (_mediaPlayer.State == VLCState.Ended)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void LoadMedia(string filePath, int audioTrackIndex = 0)
|
public void LoadMedia(string filePath, int audioTrackIndex = 0)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Console.WriteLine($"LoadMedia. in");
|
// Console.WriteLine($"LoadMedia. in");
|
||||||
|
// _media?.ParseStop();
|
||||||
|
// Console.WriteLine($"LoadMedia. ParseStop");
|
||||||
_mediaPlayer.Stop();
|
_mediaPlayer.Stop();
|
||||||
_mediaPlayer.Media = null;
|
// Console.WriteLine($"LoadMedia. Stop");
|
||||||
Console.WriteLine($"LoadMedia. Stop");
|
|
||||||
_media?.Dispose();
|
_media?.Dispose();
|
||||||
_media= null;
|
// Console.WriteLine($"LoadMedia. Dispose");
|
||||||
Console.WriteLine($"LoadMedia. Dispose");
|
|
||||||
|
|
||||||
_media = new Media(_libVLC, filePath, FromType.FromPath);
|
_media = new Media(_libVLC, filePath, FromType.FromPath);
|
||||||
|
_media.AddOption(":avcodec-hw=dxva2");
|
||||||
|
_media.AddOption(":vout=gl");
|
||||||
_media.AddOption(":audio-output=directsound");
|
_media.AddOption(":audio-output=directsound");
|
||||||
_media.AddOption($":audio-track={audioTrackIndex}");
|
_media.AddOption($":audio-track={audioTrackIndex}");
|
||||||
|
// _media.AddOption(":start-time=0.5");
|
||||||
|
_mediaPlayer.Media = _media;
|
||||||
_mediaPlayer.Play(_media);
|
_mediaPlayer.Play(_media);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine(ex.Message);
|
Console.WriteLine(ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,28 +232,36 @@ namespace DualScreenDemo
|
|||||||
|
|
||||||
public async Task PlayNextSong()
|
public async Task PlayNextSong()
|
||||||
{
|
{
|
||||||
// 等待初始化完成(例如播放器、串口等資源尚未就緒時)
|
try
|
||||||
Console.WriteLine("開始播放下一首歌曲...");
|
|
||||||
var songToPlay = SongList.Next();
|
|
||||||
if (!songToPlay.isPublicSong)
|
|
||||||
{
|
{
|
||||||
// 若是使用者點播模式,先送出升Key的串口指令
|
// 等待初始化完成(例如播放器、串口等資源尚未就緒時)
|
||||||
if (SerialPortManager.mySerialPort != null && SerialPortManager.mySerialPort.IsOpen)
|
Console.WriteLine("開始播放下一首歌曲...");
|
||||||
|
var songToPlay = SongList.Next();
|
||||||
|
if (!songToPlay.isPublicSong)
|
||||||
{
|
{
|
||||||
byte[] commandBytesIncreasePitch1 = new byte[] { 0xA2, 0x7F, 0xA4 };
|
// 若是使用者點播模式,先送出升Key的串口指令
|
||||||
SerialPortManager.mySerialPort.Write(commandBytesIncreasePitch1, 0, commandBytesIncreasePitch1.Length);
|
if (SerialPortManager.mySerialPort != null && SerialPortManager.mySerialPort.IsOpen)
|
||||||
|
{
|
||||||
|
byte[] commandBytesIncreasePitch1 = new byte[] { 0xA2, 0x7F, 0xA4 };
|
||||||
|
SerialPortManager.mySerialPort.Write(commandBytesIncreasePitch1, 0, commandBytesIncreasePitch1.Length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// 更新畫面上顯示的下一首歌資訊
|
||||||
|
SongList.UpdateNextSongLabel();
|
||||||
|
|
||||||
|
// 顯示 QRCode(可能是點歌頁用)
|
||||||
|
overlayForm.DisplayQRCodeOnOverlay(HttpServer.randomFolderPath);
|
||||||
|
|
||||||
|
// 隱藏「暫停中」標籤
|
||||||
|
overlayForm.HidePauseLabel();
|
||||||
|
|
||||||
|
await _InitializeAndPlayMedia(songToPlay);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
}
|
}
|
||||||
// 更新畫面上顯示的下一首歌資訊
|
|
||||||
SongList.UpdateNextSongLabel();
|
|
||||||
|
|
||||||
// 顯示 QRCode(可能是點歌頁用)
|
|
||||||
overlayForm.DisplayQRCodeOnOverlay(HttpServer.randomFolderPath);
|
|
||||||
|
|
||||||
// 隱藏「暫停中」標籤
|
|
||||||
overlayForm.HidePauseLabel();
|
|
||||||
|
|
||||||
await _InitializeAndPlayMedia(songToPlay);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -347,7 +355,7 @@ namespace DualScreenDemo
|
|||||||
|
|
||||||
// 音量處理
|
// 音量處理
|
||||||
//SetVolume(isMuted ? 0 : previousVolume);
|
//SetVolume(isMuted ? 0 : previousVolume);
|
||||||
if(isMuted){ Mute(true); }
|
if (isMuted) { Mute(true); }
|
||||||
SetVolume(100 + song.getBasic().getDbChange());
|
SetVolume(100 + song.getBasic().getDbChange());
|
||||||
if (isSyncToPrimaryMonitor) SyncToPrimaryMonitor();
|
if (isSyncToPrimaryMonitor) SyncToPrimaryMonitor();
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
@ -379,7 +387,7 @@ namespace DualScreenDemo
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_mediaService0.IsAtEnd() || _mediaService1.IsAtEnd())
|
if (_mediaService1.IsAtEnd())
|
||||||
{
|
{
|
||||||
BeginInvoke(new Action(async () =>
|
BeginInvoke(new Action(async () =>
|
||||||
{
|
{
|
||||||
@ -498,7 +506,7 @@ namespace DualScreenDemo
|
|||||||
}
|
}
|
||||||
private bool _ToggleVocalRemoval(bool isVocal)
|
private bool _ToggleVocalRemoval(bool isVocal)
|
||||||
{
|
{
|
||||||
_mediaService0.Mute(isVocal);
|
_mediaService0.Mute(isVocal);
|
||||||
_mediaService1.Mute(!isVocal);
|
_mediaService1.Mute(!isVocal);
|
||||||
return isVocal;
|
return isVocal;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user