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.
112 lines
3.5 KiB
112 lines
3.5 KiB
using CPF; |
|
using CPF.Animation; |
|
using CPF.Controls; |
|
using CPF.Drawing; |
|
using System; |
|
using System.Text; |
|
|
|
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) |
|
{ |
|
//注册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); |
|
} |
|
|
|
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 = "320"; |
|
Width = "640"; |
|
Background = "#2c2c2c"; |
|
ZIndex = 100; |
|
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" }; |
|
} |
|
}
|
|
|