Silverlight MediaElement 位置与生成的 WAV(性能)

发布于 2024-10-12 22:10:02 字数 795 浏览 7 评论 0原文

我已将 MediaElement 控件绑定到 Slider 控件。
我正在从 SQL Server 数据库中的二进制字段获取流。
我担心由于以下原因可能会出现一些性能问题:
1. 我正在存储从 Web 服务检索的字节数组
2. 每当我对 MediaElement 执行任何操作(即重置位置、停止播放、恢复播放)时,我都必须重置 MediaElement 的源
我用来设置位置的代码如下:

private void ResetPlayerWithPosition(double milliseconds = 0)
{
    // _wmss is a WaveMediaStreamSource from WAVMss.dll
    // audio is of type byte[]
    this._wmss = new WaveMediaStreamSource(new MemoryStream(this.audio));
    this.playbackController.SetSource(this._wmss);
    this.playbackController.MediaOpened += (s, e) =>
    {
        this.playbackController.Position = TimeSpan.FromMilliseconds(milliseconds);
    };
}

我担心的是,如果文件变得很大,则性能会下降,因为代码必须等待文件加载到 MediaElement 的源中在位置重置之前。如果是这种情况,有人对我如何提高效率有任何建议吗?

预先感谢您的任何建议。

I have tied a MediaElement control to a Slider control.
I am getting my stream from a binary field in a SQL Server database.
I am concerned that there may be some performance issues due to the following:
1. I am storing a byte array that is being retrieved from a web service
2. Anytime I do anything with the MediaElement (i.e. reset position, stop playback, resume playback) I have to reset the source of the MediaElement
The code I am using to set the position is as follows:

private void ResetPlayerWithPosition(double milliseconds = 0)
{
    // _wmss is a WaveMediaStreamSource from WAVMss.dll
    // audio is of type byte[]
    this._wmss = new WaveMediaStreamSource(new MemoryStream(this.audio));
    this.playbackController.SetSource(this._wmss);
    this.playbackController.MediaOpened += (s, e) =>
    {
        this.playbackController.Position = TimeSpan.FromMilliseconds(milliseconds);
    };
}

My concern is that if the file gets to be large, there will be performance degradation in that the code has to wait for the file to be loaded into the MediaElement's source before the position is reset. If this is the case, does anyone have any suggestions as to how I could make it a bit more efficient?

Thanks in advance for any suggestions.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

っ左 2024-10-19 22:10:02

距离我第一次发布这篇文章已经过去了 1 年 10 个月 14 天,甚至没有评论或后续问题。在这段时间里,iOS 取得了许多进步,Android 发布了一些新风格,HTML5 和 jQuery 已经优雅地成熟,而微软已经放弃了 Silverlight 而转而使用 Metro。

我已经放弃了这个解决方案,因为支持很少并且正在走向不存在。作为 Silverlight 的交换,我选择了 HTML5 + jQuery 解决方案。这使我能够在更短的开发时间内开发出轻量级、Web 方法驱动、支持 AJAX、独立于浏览器+设备+服务器的跨平台客户端,并具有更大的灵活性、可持续性和可维护性。

Silverlight:另一种高度创新但效率极低的技术已被淘汰。安息吧。

It's been 1 year 10 months 14 days since I first posted this, and not even a comment or follow-up question. In this time, iOS has made many advancements, Android has released some new flavors, HTML5 and jQuery have matured gracefully, and Microsoft has abandoned Silverlight for Metro.

I have abandoned this solution since support is sparse and on its way to nonexistence. In exchange for Silverlight, I have opted for a HTML5 + jQuery solution. This has enabled me to develop a light weight, Web Method driven, AJAX enabled, browser + device + server independent, cross-platform client in a reduced development time with more flexibility, sustainability, and maintainability.

Silverlight: Another highly innovative yet grossly inefficient technology laid to rest. RIP.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文