Advertisement
TexKiller

Playlist.hpp

Feb 22nd, 2012
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.22 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////
  2. //
  3. // SFML - Simple and Fast Multimedia Library
  4. // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
  5. //
  6. // This software is provided 'as-is', without any express or implied warranty.
  7. // In no event will the authors be held liable for any damages arising from the use of this software.
  8. //
  9. // Permission is granted to anyone to use this software for any purpose,
  10. // including commercial applications, and to alter it and redistribute it freely,
  11. // subject to the following restrictions:
  12. //
  13. // 1. The origin of this software must not be misrepresented;
  14. //    you must not claim that you wrote the original software.
  15. //    If you use this software in a product, an acknowledgment
  16. //    in the product documentation would be appreciated but is not required.
  17. //
  18. // 2. Altered source versions must be plainly marked as such,
  19. //    and must not be misrepresented as being the original software.
  20. //
  21. // 3. This notice may not be removed or altered from any source distribution.
  22. //
  23. ////////////////////////////////////////////////////////////
  24.  
  25. #ifndef SFML_PLAYLIST_HPP
  26. #define SFML_PLAYLIST_HPP
  27.  
  28. ////////////////////////////////////////////////////////////
  29. // Headers
  30. ////////////////////////////////////////////////////////////
  31. #include <SFML/Audio/SoundStream.hpp>
  32. #include <SFML/System/Mutex.hpp>
  33. #include <SFML/System/Time.hpp>
  34. #include <string>
  35. #include <vector>
  36.  
  37.  
  38. namespace sf {
  39.     namespace priv {
  40.         class SoundFile;
  41.  
  42.         ////////////////////////////////////////////////////////////
  43.         /// \brief Structure defining an item from the playlist
  44.         ///
  45.         ////////////////////////////////////////////////////////////
  46.         class Item {
  47.             public :
  48.                 priv::SoundFile* myFile;
  49.                 Time             start;
  50.                 Time             duration;
  51.                 unsigned int     returnTo;
  52.                 unsigned int     returnCount;
  53.                 unsigned int     timesReturned;
  54.         };
  55.     }
  56.  
  57.     class SFML_AUDIO_API Playlist : public SoundStream {
  58.         public :
  59.                                      Playlist(std::size_t BufferSize = 44100);
  60.                                     ~Playlist();
  61.             unsigned int             AddItem(std::string file, Time start = Time::Zero, Time end = Time::Zero, unsigned int returnTo = 0, int returnCount = 0);
  62.             void                     SetRepeat(bool repeat);
  63.             void                     Stop();
  64.             Time                     GetDuration() const;
  65.             static const int         ALWAYS_RETURN;
  66.         private :
  67.             virtual void             OnSeek(Time time);
  68.             virtual bool             OnStart();
  69.             virtual bool             OnGetData(Chunk& Data);
  70.             std::vector<priv::Item*> items;
  71.             unsigned int             currentItem;
  72.             bool                     reset;
  73.             Time                     offset;
  74.             bool                     repeat;
  75.             Time                     myDuration;
  76.             std::vector<Int16>       mySamples;
  77.             Mutex                    myMutex;
  78.     };
  79. } // namespace sf
  80.  
  81.  
  82. #endif // SFML_PLAYLIST_HPP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement