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.

227 lines
7.9KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCE_QUICKTIMEMOVIECOMPONENT_JUCEHEADER__
  19. #define __JUCE_QUICKTIMEMOVIECOMPONENT_JUCEHEADER__
  20. // (NB: This stuff mustn't go inside the "#if QUICKTIME" block, or it'll break the
  21. // amalgamated build)
  22. #ifndef DOXYGEN
  23. #if JUCE_WINDOWS
  24. typedef ActiveXControlComponent QTCompBaseClass;
  25. #elif JUCE_MAC
  26. typedef NSViewComponent QTCompBaseClass;
  27. #endif
  28. #endif
  29. #if JUCE_QUICKTIME || DOXYGEN
  30. //==============================================================================
  31. /**
  32. A window that can play back a QuickTime movie.
  33. */
  34. class JUCE_API QuickTimeMovieComponent : public QTCompBaseClass
  35. {
  36. public:
  37. //==============================================================================
  38. /** Creates a QuickTimeMovieComponent, initially blank.
  39. Use the loadMovie() method to load a movie once you've added the
  40. component to a window, (or put it on the desktop as a heavyweight window).
  41. Loading a movie when the component isn't visible can cause problems, as
  42. QuickTime needs a window handle to initialise properly.
  43. */
  44. QuickTimeMovieComponent();
  45. /** Destructor. */
  46. ~QuickTimeMovieComponent();
  47. /** Returns true if QT is installed and working on this machine.
  48. */
  49. static bool isQuickTimeAvailable() noexcept;
  50. //==============================================================================
  51. /** Tries to load a QuickTime movie from a file into the player.
  52. It's best to call this function once you've added the component to a window,
  53. (or put it on the desktop as a heavyweight window). Loading a movie when the
  54. component isn't visible can cause problems, because QuickTime needs a window
  55. handle to do its stuff.
  56. @param movieFile the .mov file to open
  57. @param isControllerVisible whether to show a controller bar at the bottom
  58. @returns true if the movie opens successfully
  59. */
  60. bool loadMovie (const File& movieFile,
  61. bool isControllerVisible);
  62. /** Tries to load a QuickTime movie from a URL into the player.
  63. It's best to call this function once you've added the component to a window,
  64. (or put it on the desktop as a heavyweight window). Loading a movie when the
  65. component isn't visible can cause problems, because QuickTime needs a window
  66. handle to do its stuff.
  67. @param movieURL the .mov file to open
  68. @param isControllerVisible whether to show a controller bar at the bottom
  69. @returns true if the movie opens successfully
  70. */
  71. bool loadMovie (const URL& movieURL,
  72. bool isControllerVisible);
  73. /** Tries to load a QuickTime movie from a stream into the player.
  74. It's best to call this function once you've added the component to a window,
  75. (or put it on the desktop as a heavyweight window). Loading a movie when the
  76. component isn't visible can cause problems, because QuickTime needs a window
  77. handle to do its stuff.
  78. @param movieStream a stream containing a .mov file. The component may try
  79. to read the whole stream before playing, rather than
  80. streaming from it.
  81. @param isControllerVisible whether to show a controller bar at the bottom
  82. @returns true if the movie opens successfully
  83. */
  84. bool loadMovie (InputStream* movieStream,
  85. bool isControllerVisible);
  86. /** Closes the movie, if one is open. */
  87. void closeMovie();
  88. /** Returns the movie file that is currently open.
  89. If there isn't one, this returns File::nonexistent
  90. */
  91. File getCurrentMovieFile() const;
  92. /** Returns true if there's currently a movie open. */
  93. bool isMovieOpen() const;
  94. /** Returns the length of the movie, in seconds. */
  95. double getMovieDuration() const;
  96. /** Returns the movie's natural size, in pixels.
  97. You can use this to resize the component to show the movie at its preferred
  98. scale.
  99. If no movie is loaded, the size returned will be 0 x 0.
  100. */
  101. void getMovieNormalSize (int& width, int& height) const;
  102. /** This will position the component within a given area, keeping its aspect
  103. ratio correct according to the movie's normal size.
  104. The component will be made as large as it can go within the space, and will
  105. be aligned according to the justification value if this means there are gaps at
  106. the top or sides.
  107. */
  108. void setBoundsWithCorrectAspectRatio (const Rectangle<int>& spaceToFitWithin,
  109. const RectanglePlacement& placement);
  110. /** Starts the movie playing. */
  111. void play();
  112. /** Stops the movie playing. */
  113. void stop();
  114. /** Returns true if the movie is currently playing. */
  115. bool isPlaying() const;
  116. /** Moves the movie's position back to the start. */
  117. void goToStart();
  118. /** Sets the movie's position to a given time. */
  119. void setPosition (double seconds);
  120. /** Returns the current play position of the movie. */
  121. double getPosition() const;
  122. /** Changes the movie playback rate.
  123. A value of 1 is normal speed, greater values play it proportionately faster,
  124. smaller values play it slower.
  125. */
  126. void setSpeed (float newSpeed);
  127. /** Changes the movie's playback volume.
  128. @param newVolume the volume in the range 0 (silent) to 1.0 (full)
  129. */
  130. void setMovieVolume (float newVolume);
  131. /** Returns the movie's playback volume.
  132. @returns the volume in the range 0 (silent) to 1.0 (full)
  133. */
  134. float getMovieVolume() const;
  135. /** Tells the movie whether it should loop. */
  136. void setLooping (bool shouldLoop);
  137. /** Returns true if the movie is currently looping.
  138. @see setLooping
  139. */
  140. bool isLooping() const;
  141. /** True if the native QuickTime controller bar is shown in the window.
  142. @see loadMovie
  143. */
  144. bool isControllerVisible() const;
  145. //==============================================================================
  146. /** @internal */
  147. void paint (Graphics& g);
  148. private:
  149. //==============================================================================
  150. File movieFile;
  151. bool movieLoaded, controllerVisible, looping;
  152. #if JUCE_WINDOWS
  153. void parentHierarchyChanged();
  154. void visibilityChanged();
  155. void createControlIfNeeded();
  156. bool isControlCreated() const;
  157. class Pimpl;
  158. friend class ScopedPointer <Pimpl>;
  159. ScopedPointer <Pimpl> pimpl;
  160. #else
  161. void* movie;
  162. #endif
  163. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (QuickTimeMovieComponent);
  164. };
  165. #endif
  166. #endif // __JUCE_QUICKTIMEMOVIECOMPONENT_JUCEHEADER__