Skip to content

Commit

Permalink
给Desktop播放器增加log内容
Browse files Browse the repository at this point in the history
  • Loading branch information
CHKZL committed Jun 16, 2024
1 parent 0c39a26 commit a3c8d59
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Desktop/Views/Windows/VlcPlayWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Core;
using Core.LiveChat;
using Core.LogModule;
using Core.RuntimeObject;
using Desktop.Models;
using Desktop.Views.Windows.DanMuCanvas.BarrageParameters;
Expand Down Expand Up @@ -56,7 +57,7 @@ public class DanMuOrbitInfo
public int Time { get; set; } = 0;
}

private RoomCardClass roomCard;
private RoomCardClass roomCard=new();
public VlcPlayWindow(long uid)
{
InitializeComponent();
Expand All @@ -67,15 +68,17 @@ public VlcPlayWindow(long uid)
vlcPlayModels.VolumeVisibility = Visibility.Collapsed;
vlcPlayModels.OnPropertyChanged("VolumeVisibility");

if (roomCard.live_status.Value != 1)

if (roomCard == null || roomCard.live_status.Value != 1)
{
Log.Info(nameof(VlcPlayWindow),$"打开播放器失败,入参uid:{uid},因为{(roomCard==null?"roomCard为空":"已下播")}");
vlcPlayModels.MessageVisibility = Visibility.Visible;
vlcPlayModels.OnPropertyChanged("MessageVisibility");
vlcPlayModels.MessageText = "该直播间未开播,播放失败";
vlcPlayModels.OnPropertyChanged("MessageText");
return;
}

Log.Info(nameof(VlcPlayWindow),$"房间号:[{roomCard.RoomId}],打开播放器");

_libVLC = new LibVLC([$"--network-caching={new Random().Next(3000, 4000)}"]);
_mediaPlayer = new LibVLCSharp.Shared.MediaPlayer(_libVLC);
Expand Down Expand Up @@ -145,6 +148,7 @@ private void LiveChatListener_MessageReceived(object? sender, Core.LiveChat.Mess
/// <param name="Url"></param>
public async void PlaySteam(string Url = null)
{
Log.Info(nameof(PlaySteam),$"房间号:[{roomCard.RoomId}],播放网络路径直播流");
await Task.Run(() =>
{
if (_mediaPlayer.IsPlaying)
Expand Down Expand Up @@ -177,6 +181,7 @@ public string GeUrl()
string url = "";
if (roomCard != null && (Core.RuntimeObject.Download.HLS.GetHlsAvcUrl(roomCard, out url) || Core.RuntimeObject.Download.FLV.GetFlvAvcUrl(roomCard, out url)))
{
Log.Info(nameof(GeUrl),$"房间号:[{roomCard.RoomId}],获取到直播流地址:[{url}]");
return url;
}
return "";
Expand All @@ -195,6 +200,7 @@ private void FluentWindow_Closing(object sender, System.ComponentModel.CancelEve
_mediaPlayer.Media.ClearSlaves();
_mediaPlayer.Media = null;
}
Log.Info(nameof(PlaySteam),$"房间号:[{roomCard.RoomId}],关闭播放器");
}
if (roomCard.DownInfo.LiveChatListener.Register.Count > 0)
{
Expand Down

0 comments on commit a3c8d59

Please sign in to comment.