实例介绍
【实例截图】
点击“视频列表选择”,再需要播放前面打勾,点击“确定选择”。上边“播”放为预览,下边“OK”为桌面背景播放
点击“动画壁纸”,在下边点击“选择动画列表”,选中的打勾,关闭。上边“播”放为预览,下边“OK”为桌面背景播放
可播放本地视频、网络视频、动画作为系统桌面背景,自动循环播放列表。
可当做小工具直接使用,也可以参考代码自行修改,支持Windows 10、Windows 7。
有兴趣的可以搞一个小项目,设立一个自己的网站,可从网站更新动态桌面壁纸发送到客户端。
已将需要的库加入代码中,可调试运行(x86、允许不安全)。
支持
dvd://;"vcd://";"cdda://";"bluray://";"rtp://";"rtsp://";"http://";"udp://";"mms://";"dshow://";
"screen://";"fake://";"imem://";...........
等方式,
支持文件类型:
"*.3g2","*.3pg","*.3gp2","*.3gpp","*.amv","*.asf","*.avi","*.bik","*.divx","*.drc","*.dv","*.f4v",
"*.flv","*.gvi","*.gfx","*.m1v","*.m2v","*.m2t","*.m2ts","*.m4v","*.mkv","*.mov",
"*.mp2","*.mp2v","*.mp4","*.mp4v","*.mpe","*.mpeg","*.mpeg1","*.mpeg2","*.mpeg4",
"*.mpg","*.mpv2","*.mts","*.mtv","*.mxf","*.mxg","*.nsv","*.nuv","*.ogg","*.ogm",
"*.ogv","*.ogx","*.ps","*.rec","*.rm","*.rmvb","*.rpl","*.thp","*.tod","*.ts","*.tts","*.txd","*.vob",
"*.vro","*.webm","*.wm","*.wmv","*.wtv","*.xesc"......等。
采用VLC的DLL和FireFox的DLL,.NET为4.5版本。如需更高版本可直接从VS的NuGet中获得。
除VLC、FireFox基础DLL外,其余全部源码,并在重点部分加注了说明。
VLC与FireFox是有冲突的,代码中需进行调整可避免,已加了标注。
原VLC会有锁死情况,这里也通过代码进行了避免,在CS文件中进行查看。
注意:
如使用集成显卡,则开始壁纸播放时会挡住桌面图标,按下“Win” “D”组合键可正常使用。
public static Image TransparentImage(Image srcImage, float opacity) { float[][] nArray ={ new float[] {1, 0, 0, 0, 0}, new float[] {0, 1, 0, 0, 0}, new float[] {0, 0, 1, 0, 0}, new float[] {0, 0, 0, opacity, 0}, new float[] {0, 0, 0, 0, 1}}; ColorMatrix matrix = new ColorMatrix(nArray); ImageAttributes attributes = new ImageAttributes(); attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); Bitmap resultImage = new Bitmap(srcImage.Width, srcImage.Height); Graphics g = Graphics.FromImage(resultImage); g.DrawImage(srcImage, new Rectangle(0, 0, srcImage.Width, srcImage.Height), 0, 0, srcImage.Width, srcImage.Height, GraphicsUnit.Pixel, attributes); return resultImage; } public static class Win32 { [DllImport("user32.dll")] public static extern IntPtr FindWindow(string className, string winName); [DllImport("user32.dll")] public static extern IntPtr SendMessageTimeout(IntPtr hwnd, uint msg, IntPtr wParam, IntPtr lParam, uint fuFlage, uint timeout, IntPtr result); [DllImport("user32.dll")] public static extern bool EnumWindows(EnumWindowsProc proc, IntPtr lParam); public delegate bool EnumWindowsProc(IntPtr hwnd, IntPtr lParam); [DllImport("user32.dll")] public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string className, string winName); [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hwnd, int nCmdShow); [DllImport("user32.dll")] public static extern IntPtr SetParent(IntPtr hwnd, IntPtr parentHwnd); } public static IntPtr programIntPtr = IntPtr.Zero; public static void Init() { programIntPtr = Win32.FindWindow("Progman", null); if (programIntPtr != IntPtr.Zero) { IntPtr result = IntPtr.Zero; Win32.SendMessageTimeout(programIntPtr, 0x52c, IntPtr.Zero, IntPtr.Zero, 0, 0x3e8, result); Win32.EnumWindows((hwnd, lParam) => { if (Win32.FindWindowEx(hwnd, IntPtr.Zero, "SHELLDLL_DefView", null) != IntPtr.Zero) { IntPtr tempHwnd = Win32.FindWindowEx(IntPtr.Zero, hwnd, "WorkerW", null); Win32.ShowWindow(tempHwnd, 0); } return true; }, IntPtr.Zero); } } [DllImport("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize")] public static extern int SetProcessWorkingSetSize(IntPtr process, int minSize, int maxSize); public static void ClearMemory() { GC.Collect(); GC.WaitForPendingFinalizers(); if (Environment.OSVersion.Platform == PlatformID.Win32NT) { SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1); } }
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论