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.

137 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. */
  27. class JUCE_API VideoComponent : public Component,
  28. private Timer
  29. {
  30. public:
  31. //==============================================================================
  32. /** Creates an empty VideoComponent.
  33. Use the load() method to open a video once you've added this component to
  34. a parent (or put it on the desktop).
  35. */
  36. VideoComponent();
  37. /** Destructor. */
  38. ~VideoComponent();
  39. //==============================================================================
  40. /** Tries to load a video from a local file.
  41. @returns am error if the file failed to be loaded correctly
  42. */
  43. Result load (const File& file);
  44. /** Tries to load a video from a URL.
  45. @returns am error if the file failed to be loaded correctly
  46. */
  47. Result load (const URL& url);
  48. /** Closes the video and resets the component. */
  49. void closeVideo();
  50. /** Returns true if a video is currently open. */
  51. bool isVideoOpen() const;
  52. /** Returns the last file that was loaded.
  53. If nothing is open, or if it was a URL rather than a file, this will return File().
  54. */
  55. File getCurrentVideoFile() const;
  56. /** Returns the last URL that was loaded.
  57. If nothing is open, or if it was a file rather than a URL, this will return File().
  58. */
  59. URL getCurrentVideoURL() const;
  60. //==============================================================================
  61. /** Returns the length of the video, in seconds. */
  62. double getVideoDuration() const;
  63. /** Returns the video's natural size, in pixels.
  64. If no video is loaded, an empty rectangle will be returned.
  65. */
  66. Rectangle<int> getVideoNativeSize() const;
  67. /** Starts the video playing. */
  68. void play();
  69. /** Stops the video playing. */
  70. void stop();
  71. /** Returns true if the video is currently playing. */
  72. bool isPlaying() const;
  73. /** Sets the video's position to a given time. */
  74. void setPlayPosition (double newPositionSeconds);
  75. /** Returns the current play position of the video. */
  76. double getPlayPosition() const;
  77. /** Changes the video playback rate.
  78. A value of 1.0 is normal speed, greater values will play faster, smaller
  79. values play more slowly.
  80. */
  81. void setPlaySpeed (double newSpeed);
  82. /** Changes the video's playback volume.
  83. @param newVolume the volume in the range 0 (silent) to 1.0 (full)
  84. */
  85. void setAudioVolume (float newVolume);
  86. /** Returns the video's playback volume.
  87. @returns the volume in the range 0 (silent) to 1.0 (full)
  88. */
  89. float getAudioVolume() const;
  90. private:
  91. //==============================================================================
  92. struct Pimpl;
  93. friend struct Pimpl;
  94. friend struct ContainerDeletePolicy<Pimpl>;
  95. ScopedPointer<Pimpl> pimpl;
  96. void resized() override;
  97. void timerCallback() override;
  98. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VideoComponent)
  99. };
  100. #endif
  101. } // namespace juce