清除測試code
This commit is contained in:
parent
14ceb39153
commit
2dda501294
@ -1,6 +1,5 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
using System.Diagnostics;
|
|
||||||
using DBObj;
|
using DBObj;
|
||||||
using DualScreenDemo;
|
using DualScreenDemo;
|
||||||
namespace OverlayFormObj
|
namespace OverlayFormObj
|
||||||
@ -1516,14 +1515,11 @@ private void DisplayArtists(List<Artist> artists, int page)//歌星點進去後
|
|||||||
/* 秒數偵測BUG 測試 */
|
/* 秒數偵測BUG 測試 */
|
||||||
public void AddSongToPlaylist(SongData songData)
|
public void AddSongToPlaylist(SongData songData)
|
||||||
{
|
{
|
||||||
Stopwatch stopwatch = new Stopwatch();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
stopwatch.Start();
|
|
||||||
var filePath1 = songData.SongFilePathHost1;
|
var filePath1 = songData.SongFilePathHost1;
|
||||||
var filePath2 = songData.SongFilePathHost2;
|
var filePath2 = songData.SongFilePathHost2;
|
||||||
stopwatch.Stop();
|
|
||||||
Console.WriteLine($"[1] 檢查路徑花費: {stopwatch.ElapsedMilliseconds} ms");
|
|
||||||
|
|
||||||
if (!File.Exists(filePath1) && !File.Exists(filePath2))
|
if (!File.Exists(filePath1) && !File.Exists(filePath2))
|
||||||
{
|
{
|
||||||
@ -1532,44 +1528,26 @@ private void DisplayArtists(List<Artist> artists, int page)//歌星點進去後
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stopwatch.Restart();
|
|
||||||
var pathToPlay = File.Exists(filePath1) ? filePath1 : filePath2;
|
var pathToPlay = File.Exists(filePath1) ? filePath1 : filePath2;
|
||||||
stopwatch.Stop();
|
|
||||||
Console.WriteLine($"[2] 確定播放路徑花費: {stopwatch.ElapsedMilliseconds} ms");
|
|
||||||
bool wasEmpty = PrimaryForm.userRequestedSongs.Count == 0;
|
bool wasEmpty = PrimaryForm.userRequestedSongs.Count == 0;
|
||||||
|
|
||||||
stopwatch.Restart();
|
|
||||||
PrimaryForm.userRequestedSongs.Add(songData);
|
PrimaryForm.userRequestedSongs.Add(songData);
|
||||||
PrimaryForm.playedSongsHistory.Add(songData);
|
PrimaryForm.playedSongsHistory.Add(songData);
|
||||||
PrimaryForm.playStates.Add(wasEmpty ? PlayState.Playing : PlayState.NotPlayed);
|
PrimaryForm.playStates.Add(wasEmpty ? PlayState.Playing : PlayState.NotPlayed);
|
||||||
stopwatch.Stop();
|
|
||||||
Console.WriteLine($"[3] 加入播放清單花費: {stopwatch.ElapsedMilliseconds} ms");
|
|
||||||
// 刷新頁面
|
// 刷新頁面
|
||||||
|
|
||||||
stopwatch.Restart();
|
|
||||||
if(PrimaryForm.Instance.multiPagePanel.get_currentSongList() == PrimaryForm.playedSongsHistory)
|
if(PrimaryForm.Instance.multiPagePanel.get_currentSongList() == PrimaryForm.playedSongsHistory)
|
||||||
PrimaryForm.Instance.multiPagePanel.LoadSongs(PrimaryForm.Instance.currentSongList);
|
PrimaryForm.Instance.multiPagePanel.LoadSongs(PrimaryForm.Instance.currentSongList);
|
||||||
stopwatch.Stop();
|
|
||||||
Console.WriteLine($"[4] 更新歌曲面板花費: {stopwatch.ElapsedMilliseconds} ms");
|
|
||||||
if (wasEmpty)
|
if (wasEmpty)
|
||||||
{
|
{
|
||||||
stopwatch.Restart();
|
|
||||||
VideoPlayerForm.Instance.SetPlayingSongList(PrimaryForm.userRequestedSongs);
|
VideoPlayerForm.Instance.SetPlayingSongList(PrimaryForm.userRequestedSongs);
|
||||||
PrimaryForm.currentSongIndexInHistory += 1;
|
PrimaryForm.currentSongIndexInHistory += 1;
|
||||||
stopwatch.Stop();
|
|
||||||
Console.WriteLine($"[5] 設定播放列表花費: {stopwatch.ElapsedMilliseconds} ms");
|
|
||||||
}
|
}
|
||||||
stopwatch.Restart();
|
|
||||||
VideoPlayerForm.Instance.UpdateNextSongFromPlaylist();
|
VideoPlayerForm.Instance.UpdateNextSongFromPlaylist();
|
||||||
PrimaryForm.PrintPlayingSongList();
|
PrimaryForm.PrintPlayingSongList();
|
||||||
stopwatch.Stop();
|
|
||||||
Console.WriteLine($"[6] 更新下一首與印出列表花費: {stopwatch.ElapsedMilliseconds} ms");
|
|
||||||
|
|
||||||
// 點播次數+1
|
// 點播次數+1
|
||||||
stopwatch.Restart();
|
|
||||||
PrimaryForm.Instance.AddSongCount(songData.SongNumber);
|
PrimaryForm.Instance.AddSongCount(songData.SongNumber);
|
||||||
stopwatch.Stop();
|
|
||||||
Console.WriteLine($"[7] 新增點播次數花費: {stopwatch.ElapsedMilliseconds} ms");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using System.IO; // For StreamWriter
|
using System.IO; // For StreamWriter
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using DirectShowLib;
|
using DirectShowLib;
|
||||||
using System.Diagnostics;
|
|
||||||
using DBObj;
|
using DBObj;
|
||||||
using OverlayFormObj;
|
using OverlayFormObj;
|
||||||
namespace DualScreenDemo
|
namespace DualScreenDemo
|
||||||
@ -544,48 +543,33 @@ namespace DualScreenDemo
|
|||||||
{
|
{
|
||||||
// [1] 輸出 debug 訊息,方便開發時追蹤是否有呼叫此方法
|
// [1] 輸出 debug 訊息,方便開發時追蹤是否有呼叫此方法
|
||||||
Console.WriteLine("SetPlayingSongList called");
|
Console.WriteLine("SetPlayingSongList called");
|
||||||
Stopwatch stopwatch = new Stopwatch();
|
|
||||||
stopwatch.Start();
|
|
||||||
// [2] 停止當前播放,釋放資源(例如關閉影片播放器、清除緩衝)
|
// [2] 停止當前播放,釋放資源(例如關閉影片播放器、清除緩衝)
|
||||||
StopAndReleaseResources();
|
StopAndReleaseResources();
|
||||||
stopwatch.Stop();
|
|
||||||
Console.WriteLine($"[5-2]停止當前播放,釋放資源,耗時{stopwatch.ElapsedMilliseconds}ms");
|
|
||||||
|
|
||||||
// [3] 將新的播放清單指派給 `playingSongList`
|
// [3] 將新的播放清單指派給 `playingSongList`
|
||||||
stopwatch.Restart();
|
|
||||||
playingSongList = songList;
|
playingSongList = songList;
|
||||||
stopwatch.Stop();
|
|
||||||
Console.WriteLine($"[5-3]將新的播放清單指派,耗時{stopwatch.ElapsedMilliseconds}ms");
|
|
||||||
|
|
||||||
// [4] 根據是否有歌,設定旗標為是否播放使用者點播清單
|
// [4] 根據是否有歌,設定旗標為是否播放使用者點播清單
|
||||||
stopwatch.Restart();
|
|
||||||
isUserPlaylistPlaying = playingSongList != null && playingSongList.Any();
|
isUserPlaylistPlaying = playingSongList != null && playingSongList.Any();
|
||||||
stopwatch.Stop();
|
|
||||||
Console.WriteLine($"[5-4]根據是否有歌,設定旗標為是否播放使用者點播清單,耗時{stopwatch.ElapsedMilliseconds}ms");
|
|
||||||
|
|
||||||
// [5] 強制關閉公播狀態(意即現在進入點歌模式)
|
// [5] 強制關閉公播狀態(意即現在進入點歌模式)
|
||||||
stopwatch.Restart();
|
|
||||||
IsPlayingPublicSong = false;
|
IsPlayingPublicSong = false;
|
||||||
stopwatch.Stop();
|
|
||||||
Console.WriteLine($"[5-5]強制關閉公播狀態,耗時{stopwatch.ElapsedMilliseconds}ms");
|
|
||||||
// [6] 若使用者點播清單有歌,就開始播放
|
// [6] 若使用者點播清單有歌,就開始播放
|
||||||
if (isUserPlaylistPlaying)
|
if (isUserPlaylistPlaying)
|
||||||
{
|
{
|
||||||
stopwatch.Restart();
|
|
||||||
// [6.1] 設定當前歌曲索引為 -1(意味著即將播放第一首,從 `PlayNextSong` 開始)
|
// [6.1] 設定當前歌曲索引為 -1(意味著即將播放第一首,從 `PlayNextSong` 開始)
|
||||||
currentSongIndex = -1;
|
currentSongIndex = -1;
|
||||||
// [6.2] 播放下一首歌(實際會遞增 index 為 0,並播放該首歌)
|
// [6.2] 播放下一首歌(實際會遞增 index 為 0,並播放該首歌)
|
||||||
await PlayNextSong();
|
await PlayNextSong();
|
||||||
stopwatch.Stop();
|
|
||||||
Console.WriteLine($"[5-6]播放下一首歌,耗時{stopwatch.ElapsedMilliseconds}ms");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stopwatch.Restart();
|
|
||||||
// [7] 如果清單為空,回退播放預設的公播清單(通常是背景播放用)
|
|
||||||
await InitializeAndPlayPublicPlaylist();
|
await InitializeAndPlayPublicPlaylist();
|
||||||
stopwatch.Stop();
|
|
||||||
Console.WriteLine($"[5-7]如果清單為空,回退播放預設的公播清單,耗時{stopwatch.ElapsedMilliseconds}ms");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user