简体   繁体   English

如何在Firemonkey(FMX)中无缝循环声音?

[英]How loop a sound seamlessly in Firemonkey (FMX)?

How do you loop a sound seamlessly using the TMediaPlayer in Firemonkey (using XE6, C++ Builder)? 如何使用Firemonkey中的TMediaPlayer(使用XE6,C ++ Builder)无缝地循环播放声音?

What I am doing so far is using a TTimer which checks 到目前为止,我正在使用TTimer进行检查

if (MediaPlayer->CurrentTime >= MediaPlayer->Media->Duration)
{
  MediaPlayer->CurrentTime = 0;
  MediaPlayer->Play ();
}

but this doesn't create a seamless loop, even when the TTimer's Interval is set to 1. 但这不会创建无缝循环,即使TTimer的间隔设置为1也是如此。

Any ideas? 有任何想法吗?

I am not familiar with this component but assume, in Windows, it is a wrapper around DirectShow. 我不熟悉此组件,但假设在Windows中,它是DirectShow的包装。 That means you will never be able to get (frame) seamless playback because of the overhead of starting/stopping the graph. 这意味着由于开始/停止图形的开销,您将永远无法获得(帧)无缝播放。 If you can live with a small hiccup, you probably get the best results (and certainly better code) if there is something like an OnLastFrame() event, in which you can reset the frame counter to the first frame (or CurrentTime to zero). 如果您可以打个small,那么在发生类似OnLastFrame()事件的事件时,您可能会获得最佳结果(当然还有更好的代码),在该事件中,您可以将帧计数器重置为第一帧(或将CurrentTime重置为零) 。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM