728x90
반응형
1. UI/ XML
<Window x:Class="youtube_viewer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:youtube_viewer"
mc:Ignorable="d"
Title="YouTube Player" Height="500" Width="800"
Background="#FFE5E5E5"
>
<Grid Name="GridViewer">
<Grid.RowDefinitions>
<RowDefinition Height="215*"/>
<RowDefinition Height="27*"/>
</Grid.RowDefinitions>
<Grid Margin="0,3,0,0" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="677*"/>
<ColumnDefinition Width="123*"/>
</Grid.ColumnDefinitions>
<Button Name ="btn_play" Margin="5,10,10,10" Content="Play" Click="btn_play_Click" Grid.Column="1"/>
<TextBox Name="txtbox_url" Margin="10,10,5,10" Grid.Column="0" TextWrapping="Wrap" Text="Input youtube url" Grid.ColumnSpan="1"/>
</Grid>
</Grid>
</Window>
2. C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace youtube_viewer
{
/// <summary>
/// MainWindow.xaml에 대한 상호 작용 논리
/// </summary>
public partial class MainWindow : Window
{
CefSharp.Wpf.ChromiumWebBrowser _browser;
string str;
public MainWindow()
{
InitializeComponent();
_browser = new CefSharp.Wpf.ChromiumWebBrowser();
GridViewer.Children.Add(_browser);
}
private void btn_play_Click(object sender, RoutedEventArgs e)
{
str = txtbox_url.Text.Split('=')[1].Split('&')[0];
if (this._browser != null)
{
_browser.Address = $"https://www.youtube-nocookie.com/embed/{str}";
}
}
}
}
3. Nuget
728x90
반응형
'프로그래밍 > Windows' 카테고리의 다른 글
[Win32 API] GetCurrentDirectory : 현재 디렉토리 위치 구하기 (0) | 2022.06.01 |
---|---|
[Win32 API] PathFileExists : 파일 존재 여부 확인하기 (0) | 2022.06.01 |
[Windows] CallBack 함수 (0) | 2022.05.07 |
[WPF] OpenCvSharp4로 윈도우 안에 카메라 영상 그리기 (0) | 2022.02.02 |
[WPF] OpenCVSharp 4 Nuget 설치 (0) | 2022.02.02 |
[WPF] Visual Studio 2022 개발 환경 구축 및 프로젝트 빌드 (0) | 2020.03.15 |
댓글