采用网络对联方式交互数据
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
3.8 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CPF;
using CPF.Drawing;
using CPF.Controls;
using CPF.Shapes;
using CPF.Styling;
using CPF.Animation;
using CPF.Svg;
using CPF.Input;
using static System.Net.Mime.MediaTypeNames;
1 year ago
namespace AksWebBrowser
{
public class AksVideoPlayer : Control
{
/// <summary>
/// apt-get install libvlc-dev
/// apt-get install vlc
/// </summary>
public string videoTitle = string.Empty;
public string url = string.Empty;
private VideoView vplayer = null;
public AksVideoPlayer(Window window, string _videoTitle,string _url)
{
1 year ago
//注册gb2312
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
vplayer = new VideoView
{
Name = "player",
PresenterFor = this,
MarginTop = 50,
Size = SizeField.Fill,
Background = Color.Silver
};
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);
//this.TransitionValue(a => a.MarginTop, 100, TimeSpan.FromSeconds(0.3), new PowerEase { }, AnimateMode.EaseOut);
}
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 = "600";
Width = "800";
Background = "#2c2c2c";
ZIndex = 100;
Children.Add(new TextBlock
{
MarginRight = 12f,
MarginTop = 10f,
1 year ago
Classes = "imgAndText",
FontFamily = "微软雅黑",//Alibaba PuHuiTi
Text = "关闭",
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,
1 year ago
Classes = "imgAndText",
Foreground = Color.White,
Text = videoTitle,
1 year ago
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" };
}
}