XNA MediaPlayer 快进/快退 [英] XNA MediaPlayer fastforward/rewind

查看:32
本文介绍了XNA MediaPlayer 快进/快退的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 XNA 4.0,我目前正在使用以下方法播放用户 PC/XBox360 上的歌曲:

Using XNA 4.0, I am currently playing songs from the user's PC/XBox360 using the following:

        Microsoft.Xna.Framework.Media.MediaPlayer.Play(Song song);

我看到 MediaPlayer 有一个静态属性 PlayPosition,正如我所研究的,它曾经是一个 get/set 属性,但它已经更新为-只有.

I see that MediaPlayer has a static Property PlayPosition that, as I've researched, used to be a get/set property, but it has been updated to get-only.

我可以使用其他任何方法/技巧来明确设置当前播放歌曲的播放位置吗?

Are there any other methods/tricks I can use to explicitly set the playing position of a currently playing song?

推荐答案

看起来他们添加了一个 DynamicSoundEffectInstance 类.成员函数之一是 SubmitBuffer,其中允许您设置偏移量,以字节为单位,到数据的起始位置."

It looks liked they added a DynamicSoundEffectInstance class in XNA 4.0. One of the member functions is SubmitBuffer, which allows you to set the "Offset, in bytes, to the starting position of the data."

请注意,我还没有尝试过,我无法告诉您如何将音频放入字节缓冲区(也许您可以以某种方式从 XACT 波库中读取它?).这样做也可能会很痛苦,因为如果您决定再次更改位置,您似乎无法删除缓冲区.您要么让它播放到最后,要么创建一个新类并提交一个具有新偏移量的新缓冲区.因此,您可以将字节缓冲区保留在内存中,并在每次想要更改位置时将其传递给具有新偏移量的新 DynamicSoundEffectInstance 类.

Please note that I haven't tried this out yet, and I couldn't tell you how to get your audio into a buffer of bytes (maybe you can read it from a XACT wavebank somehow?). It's also probably going to be a pain to do this because it doesn't look like you can remove the buffer if you decide to change position again. You would have to either let it play to the end or create a new class and submit a new buffer with a new offset. So you could keep your byte buffer in memory, and just pass it to new DynamicSoundEffectInstance classes with a new offset each time you wanted to change position.

就像我说的,我还没有尝试过,我只是通过 MSDN 上的文档.我四处搜索了一下,Shawn Hargreaves 回来在 09 年 10 月 XNA 4.0 出来之前,他认为这不可能做到.由于 PlayPosition 在 XNA 4.0 中仍然是一个 get only 属性,我认为您在那里不会有任何运气,但 DynamicSoundEffectInstance 是新的,可能会提供您需要的东西.

Like I said, I haven't tried this out yet, and I'm just going by the documentation on MSDN. I searched around for a while, and Shawn Hargreaves said back in October '09 before XNA 4.0 came out that he doesn't think this can be done. Since the PlayPosition is still a get only property in XNA 4.0, I don't think you'll have any luck there, but the DynamicSoundEffectInstance is new and may give you what you need.

这篇关于XNA MediaPlayer 快进/快退的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆