The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines
4.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_VIDEOCOMPONENT_H_INCLUDED
  18. #define JUCE_VIDEOCOMPONENT_H_INCLUDED
  19. namespace juce
  20. {
  21. //==============================================================================
  22. /**
  23. A component that can play a movie.
  24. Use the load() method to open a video once you've added this component to
  25. a parent (or put it on the desktop).
  26. @tags{Video}
  27. */
  28. class JUCE_API VideoComponent : public Component,
  29. private Timer
  30. {
  31. public:
  32. //==============================================================================
  33. /** Creates an empty VideoComponent.
  34. Use the load() method to open a video once you've added this component to
  35. a parent (or put it on the desktop).
  36. */
  37. VideoComponent();
  38. /** Destructor. */
  39. ~VideoComponent();
  40. //==============================================================================
  41. /** Tries to load a video from a local file.
  42. @returns an error if the file failed to be loaded correctly
  43. */
  44. Result load (const File& file);
  45. /** Tries to load a video from a URL.
  46. @returns an error if the file failed to be loaded correctly
  47. */
  48. Result load (const URL& url);
  49. /** Closes the video and resets the component. */
  50. void closeVideo();
  51. /** Returns true if a video is currently open. */
  52. bool isVideoOpen() const;
  53. /** Returns the last file that was loaded.
  54. If nothing is open, or if it was a URL rather than a file, this will return File().
  55. */
  56. File getCurrentVideoFile() const;
  57. /** Returns the last URL that was loaded.
  58. If nothing is open, or if it was a file rather than a URL, this will return URL().
  59. */
  60. URL getCurrentVideoURL() const;
  61. //==============================================================================
  62. /** Returns the length of the video, in seconds. */
  63. double getVideoDuration() const;
  64. /** Returns the video's natural size, in pixels.
  65. If no video is loaded, an empty rectangle will be returned.
  66. */
  67. Rectangle<int> getVideoNativeSize() const;
  68. /** Starts the video playing. */
  69. void play();
  70. /** Stops the video playing. */
  71. void stop();
  72. /** Returns true if the video is currently playing. */
  73. bool isPlaying() const;
  74. /** Sets the video's position to a given time. */
  75. void setPlayPosition (double newPositionSeconds);
  76. /** Returns the current play position of the video. */
  77. double getPlayPosition() const;
  78. /** Changes the video playback rate.
  79. A value of 1.0 is normal speed, greater values will play faster, smaller
  80. values play more slowly.
  81. */
  82. void setPlaySpeed (double newSpeed);
  83. /** Changes the video's playback volume.
  84. @param newVolume the volume in the range 0 (silent) to 1.0 (full)
  85. */
  86. void setAudioVolume (float newVolume);
  87. /** Returns the video's playback volume.
  88. @returns the volume in the range 0 (silent) to 1.0 (full)
  89. */
  90. float getAudioVolume() const;
  91. private:
  92. //==============================================================================
  93. struct Pimpl;
  94. friend struct Pimpl;
  95. friend struct ContainerDeletePolicy<Pimpl>;
  96. std::unique_ptr<Pimpl> pimpl;
  97. void resized() override;
  98. void timerCallback() override;
  99. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VideoComponent)
  100. };
  101. #endif
  102. } // namespace juce