当前位置: 首页 > news >正文

电子系统设计网站html网站管理

电子系统设计网站,html网站管理,建设门户网站申请,投资者互动平台介绍 在实际的开发过程中#xff0c;需要在应用内部内嵌播放器进行视频的播放。官方默认的MediaElement控件只能播放有限的视频格式#xff0c;也不能播放网络流。比较流行的解决方式是vlc的库#xff0c;但是在实际使用过程中发现有很多问题。这里给大家推荐另一个比较好的…介绍 在实际的开发过程中需要在应用内部内嵌播放器进行视频的播放。官方默认的MediaElement控件只能播放有限的视频格式也不能播放网络流。比较流行的解决方式是vlc的库但是在实际使用过程中发现有很多问题。这里给大家推荐另一个比较好的库。 使用 官网地址 安装库 Nuget下安装FFME.Windows PM Install-Package FFME.Windows下载ffmpeg依赖 注官网给的地址我在实际使用中发现使用官方的代码没问题使用给定的步骤使用就会抱错如果你们跟我一样给大家推荐另一个ffmpeg包的地址 ffmpeg依赖下载地址 代码 指定ffmpeg库的地址 Unosquare.FFME.Library.FFmpegDirectory C:\ffmpeg\ffmpeg-4.4-windows-desktop-vs2022-gpl-lite\bin;xaml中插入控件 Window x:ClassWpfApp1.MainWindowxmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:dhttp://schemas.microsoft.com/expression/blend/2008xmlns:mchttp://schemas.openxmlformats.org/markup-compatibility/2006xmlns:localclr-namespace:WpfApp1 xmlns:ffmeclr-namespace:Unosquare.FFME;assemblyffme.winmc:IgnorabledLoadedWindow_LoadedClosedWindow_ClosedTitleMainWindow Height300 Width600Gridffme:MediaElement x:NameMedia BackgroundGray LoadedBehaviorPlay UnloadedBehaviorManual /Button ContentPlay ClickPlayButton_Click HorizontalAlignmentLeft VerticalAlignmentTop Width75 Margin10/Button ContentStop ClickStopButton_Click HorizontalAlignmentLeft VerticalAlignmentTop Width75 Margin100,10,0,0//Grid /Window 监听失败的事件 Media.MediaFailed OnMediaFailed;创建一个处理流地址的类FileInputStream namespace Unosquare.FFME.Windows.Sample.Foundation;using Common; using FFmpeg.AutoGen; using System; using System.IO; using System.Runtime.InteropServices;/// inheritdoc / /// summary /// Provides an example of a very simple custom input stream. /// /summary /// seealso crefIMediaInputStream / public sealed unsafe class FileInputStream : IMediaInputStream {private readonly FileStream BackingStream;private readonly object ReadLock new();private readonly byte[] ReadBuffer;/// summary/// Initializes a new instance of the see crefFileInputStream/ class./// /summary/// param namepathThe path./parampublic FileInputStream(string path){var fullPath Path.GetFullPath(path);BackingStream File.OpenRead(fullPath);var uri new Uri(fullPath);StreamUri new Uri(uri.ToString().ReplaceOrdinal(file://, Scheme));CanSeek true;ReadBuffer new byte[ReadBufferLength];}/// summary/// The custom file scheme (URL prefix) including the :// sequence./// /summarypublic static string Scheme customfile://;/// inheritdoc /public Uri StreamUri { get; }/// inheritdoc /public bool CanSeek { get; }/// inheritdoc /public int ReadBufferLength 1024 * 16;/// inheritdoc /public InputStreamInitializing OnInitializing { get; }/// inheritdoc /public InputStreamInitialized OnInitialized { get; }/// inheritdoc /public void Dispose(){BackingStream?.Dispose();}/// summary/// Reads from the underlying stream and writes up to paramref nametargetBufferLength / bytes/// to the paramref nametargetBuffer /. Returns the number of bytes that were written./// /summary/// param nameopaqueThe opaque./param/// param nametargetBufferThe target buffer./param/// param nametargetBufferLengthLength of the target buffer./param/// returns/// The number of bytes that have been read./// /returnspublic int Read(void* opaque, byte* targetBuffer, int targetBufferLength){lock (ReadLock){try{var readCount BackingStream.Read(ReadBuffer, 0, ReadBuffer.Length);if (readCount 0)Marshal.Copy(ReadBuffer, 0, (IntPtr)targetBuffer, readCount);else if (readCount 0)return ffmpeg.AVERROR_EOF;return readCount;}catch (Exception){return ffmpeg.AVERROR_EOF;}}}/// inheritdoc /public long Seek(void* opaque, long offset, int whence){lock (ReadLock){try{return whence ffmpeg.AVSEEK_SIZE ?BackingStream.Length : BackingStream.Seek(offset, SeekOrigin.Begin);}catch{return ffmpeg.AVERROR_EOF;}}} } 播放视频 //var target new Uri(rtmp://127.0.0.1/live/test1231233); var target new Uri(D:\视频\泥坑.mp4); if (target.ToString().StartsWith(FileInputStream.Scheme, StringComparison.OrdinalIgnoreCase))await Media.Open(new FileInputStream(target.LocalPath)); elseawait Media.Open(target);
http://www.hkea.cn/news/14367467/

相关文章:

  • 重庆网站设计软文推广营销平台
  • 做汽车价格的网站教育 企业 重庆网站建设
  • 做徽商要做网站吗安阳网站自然优化
  • 有什么网站做图片宣传海报wordpress 755权限
  • 物流网站的建设下班后做兼职任务网站
  • 五和网站建设seo 能提高网站速度吗
  • 未备案网站如何加cdn龙岩网站建设行情
  • 亳州做企业网站大连优化网站
  • 做网站的人叫什么软件网络商城平台怎么做
  • 网站建设提问wordpress显示代码框
  • 国内论坛网站有哪些wordpress 清理 数据库
  • 高权重网站怎么做重庆住建网站
  • 怎样进行网站后台管理支付网站建设费用做账
  • 晋江网站设计泉州名扬专业金华网站建设团队
  • 上海网站建设制作公司如何只做网站
  • 企业网站的制作与维护wordpress视频类模板下载
  • 有什么网站可以做免费推广广西网络推广公司
  • h5自适应网站源码华为外包一般能干多久
  • wordpress 站点打开慢lunix安装wordpress
  • 免备案做网站可以盈利吗开发和研发的区别
  • dede程序数据库还原图文教程★适合dede网站迁移铜陵市建设工程管理局网站
  • 在哪做网站关键词苏州高级网站建设
  • 深圳网站建设哪家强厦门网页设计代做
  • 做电影网站资源哪里来的杭州网站设计询问蓝韵网络
  • 网站怎么做留言提交功能云猎建筑人才网
  • 梅州哪里做网站企业建设网站怎么做账
  • 慈溪企业排名网站中国移动积分兑换商城官方网站
  • 花钱人做的网站做好后算谁的莱芜二手房网
  • 一个域名一个主机可以做两个网站吗如何重新编辑wordpress
  • 餐饮网站建设目标做企业网站价格