Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - tangor

Pages: [1]
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:
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;
}

 

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

Pages: [1]