using CPF; using CPF.Animation; using CPF.Controls; using CPF.Drawing; using System; using System.Text; namespace AksWebBrowser { public class AksVideoPlayer : Control { /// /// apt-get install libvlc-dev /// apt-get install vlc /// public string videoTitle = string.Empty; public string url = string.Empty; private VideoView vplayer = null; public AksVideoPlayer(Window window, string _videoTitle,string _url) { //注册gb2312 Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); vplayer = new VideoView { Name = "player", PresenterFor = this, MarginTop = 750, Size = SizeField.Fill, Background = Color.Silver, Height=600, }; videoTitle = _videoTitle; url = _url; this.window = window; window.Children.Add(mask); window.Children.Add(this); mask.TransitionValue(a => a.Background, "0,0,0,100", TimeSpan.FromSeconds(0.3), null, AnimateMode.Linear); } private Window window; protected override void OnInitialized() { base.OnInitialized(); //@"http://192.168.0.34:92/CaseFile/card/2024-06-03/20240603120112952.mp4" vplayer.Play(new Uri(url));//播放 } protected override void InitializeComponent() { IsAntiAlias = true; CornerRadius = "3,3,3,3"; Height = "1920"; Width = "1080"; Background = "#2c2c2c"; ZIndex = 100; //WindowState = WindowState = WindowState.FullScreen; Children.Add(new TextBlock { MarginRight = 12f, MarginTop = 10f, Classes = "imgAndText", FontFamily = "微软雅黑",//Alibaba PuHuiTi Text = "X", FontSize = 16, Cursor = CPF.Cursors.Hand, Foreground = Color.White, ZIndex = 101, Commands = { { nameof(MouseDown), (s,e)=>Close() } }, Triggers = { { nameof(IsMouseOver), Relation.Me, null, (nameof(Foreground),Color.White) } } }); Children.Add(new TextBlock { FontSize = 16f, MarginLeft = 12.6f, MarginTop = 9.6f, Classes = "imgAndText", Foreground = Color.White, Text = videoTitle, FontFamily = "微软雅黑", }); Children.Add(vplayer); } public void Close() { vplayer.Stop(); mask.TransitionValue(a => a.Background, "0,0,0,0", TimeSpan.FromSeconds(0.3), null, AnimateMode.Linear, () => { window.Children.Remove(mask); }); this.TransitionValue(a => a.MarginTop, -100, TimeSpan.FromSeconds(0.3), new PowerEase { }, AnimateMode.EaseIn, () => { window.Children.Remove(this); }); } Control mask = new Control { Size = SizeField.Fill, ZIndex = 100, Background = "#00000000" }; } }