1
Audio / Trouble with setPlayingOffset()
« on: September 15, 2015, 07:22:06 pm »
If I set setPlayingOffset() over more than 50% of .flac file, music restarts playing.
For example: music.setPlayingOffset(sf::seconds(200); (music duration is equal 300 seconds). This causes playing music from the beginning.
If I open .ogg file, everything works well- I can set every value which is less than music.getDuration();
Here is code:
I check it for several .flac files, which duration is between 2-4minutes. In each is the same bug.
I use SFML for visual studio 2010 32-bit
For example: music.setPlayingOffset(sf::seconds(200); (music duration is equal 300 seconds). This causes playing music from the beginning.
If I open .ogg file, everything works well- I can set every value which is less than music.getDuration();
Here is code:
void playMusic(std::string bob)
{
// Load an ogg music file
sf::Music music;
if (!music.openFromFile(bob))
return;
// Display music informations
std::cout << "orchestral.ogg :" << std::endl;
std::cout << " " << music.getDuration().asSeconds() << " seconds" << std::endl;
std::cout << " " << music.getSampleRate() << " samples / sec" << std::endl;
std::cout << " " << music.getChannelCount() << " channels" << std::endl;
// Play it
music.play();
music.setPlayingOffset(sf::seconds(200));
// Loop while the music is playing
while (music.getStatus() == sf::Music::Playing)
{
// Leave some CPU time for other processes
sf::sleep(sf::milliseconds(100));
// Display the playing position
std::cout << "\rPlaying... " << std::fixed << std::setprecision(2) << music.getPlayingOffset().asSeconds() << " sec ";
std::cout << std::flush;
}
std::cout << std::endl;
}
{
// Load an ogg music file
sf::Music music;
if (!music.openFromFile(bob))
return;
// Display music informations
std::cout << "orchestral.ogg :" << std::endl;
std::cout << " " << music.getDuration().asSeconds() << " seconds" << std::endl;
std::cout << " " << music.getSampleRate() << " samples / sec" << std::endl;
std::cout << " " << music.getChannelCount() << " channels" << std::endl;
// Play it
music.play();
music.setPlayingOffset(sf::seconds(200));
// Loop while the music is playing
while (music.getStatus() == sf::Music::Playing)
{
// Leave some CPU time for other processes
sf::sleep(sf::milliseconds(100));
// Display the playing position
std::cout << "\rPlaying... " << std::fixed << std::setprecision(2) << music.getPlayingOffset().asSeconds() << " sec ";
std::cout << std::flush;
}
std::cout << std::endl;
}
I check it for several .flac files, which duration is between 2-4minutes. In each is the same bug.
I use SFML for visual studio 2010 32-bit