Skip to content

Commit

Permalink
doc: 添加项目描述
Browse files Browse the repository at this point in the history
  • Loading branch information
K12f committed Sep 3, 2024
1 parent e87cf54 commit 92d3bd9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/BlueCatKoKo.Ui/ViewModels/Pages/HomeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public HomeViewModel(IMessenger messenger, ILogger logger, DouyinDownloaderServi

LibVlc = new LibVLC();
MediaPlayer = new MediaPlayer(LibVlc);

MediaPlayer.EnableMouseInput = true;
//通过设置宽高比为窗体宽高可达到视频铺满全屏的效果
MediaPlayer.AspectRatio = MediaPlayerWidth + ":" + MediaPlayerHeight;
Expand Down Expand Up @@ -139,10 +140,10 @@ private async Task Parse()
};

// 绑定视频
using (Media media = new(LibVlc, new Uri(Data.VideoUrl)))
{
MediaPlayer.Play(media);
}
using Media media = new(LibVlc, new Uri(Data.VideoUrl));
// 这里设置选项,防止自动播放
MediaPlayer.Media = media;
MediaPlayer.Pause();
}
catch (Exception ex)
{
Expand All @@ -158,6 +159,24 @@ private async Task Parse()
}
}

[RelayCommand]
private void PlayVideo()
{
if (!MediaPlayer.IsPlaying)
{
MediaPlayer.Play();
}
}

[RelayCommand]
private void PauseVideo()
{
if (MediaPlayer.IsPlaying)
{
MediaPlayer.Pause();
}
}

[RelayCommand]
private async Task DownloadAll()
{
Expand Down
4 changes: 4 additions & 0 deletions src/BlueCatKoKo.Ui/Views/Pages/HomePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
Background="Gainsboro" />
<!-- <CheckBox Margin="0,16,0,0" Content="视频" IsChecked="{Binding ViewModel.IsDownloadVideo}"/> -->
<!-- <CheckBox Margin="0,16,0,0" Content="音频" IsChecked="{Binding ViewModel.IsDownloadAudio}"/> -->
<Button Content="播放视频" Command="{Binding ViewModel.PlayVideoCommand}"
Style="{StaticResource ButtonPrimary}" />
<Button Content="暂停视频" Command="{Binding ViewModel.PauseVideoCommand}"
Style="{StaticResource ButtonInfo}" />
<Button Content="一键下载" Command="{Binding ViewModel.DownloadAllCommand}"
Style="{StaticResource ButtonSuccess}" />
</hc:UniformSpacingPanel>
Expand Down

0 comments on commit 92d3bd9

Please sign in to comment.