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.

118 lines
3.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software 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. #include "../jucedemo_headers.h"
  18. #if JUCE_QUICKTIME && ! JUCE_LINUX
  19. //==============================================================================
  20. // so that we can easily have two QT windows each with a file browser, wrap this up as a class..
  21. class QuickTimeWindowWithFileBrowser : public Component,
  22. public FilenameComponentListener
  23. {
  24. public:
  25. QuickTimeWindowWithFileBrowser()
  26. : fileChooser ("movie", File::nonexistent, true, false, false,
  27. "*", String::empty, "(choose a video file to play)")
  28. {
  29. addAndMakeVisible (&qtComp);
  30. addAndMakeVisible (&fileChooser);
  31. fileChooser.addListener (this);
  32. fileChooser.setBrowseButtonText ("browse");
  33. }
  34. ~QuickTimeWindowWithFileBrowser()
  35. {
  36. }
  37. void resized()
  38. {
  39. qtComp.setBounds (0, 0, getWidth(), getHeight() - 30);
  40. fileChooser.setBounds (0, getHeight() - 24, getWidth(), 24);
  41. }
  42. void filenameComponentChanged (FilenameComponent*)
  43. {
  44. // this is called when the user changes the filename in the file chooser box
  45. if (qtComp.loadMovie (fileChooser.getCurrentFile(), true))
  46. {
  47. // loaded the file ok, so let's start it playing..
  48. qtComp.play();
  49. }
  50. else
  51. {
  52. AlertWindow::showMessageBox (AlertWindow::WarningIcon,
  53. "Couldn't load the file!",
  54. "Sorry, QuickTime didn't manage to load that file!");
  55. }
  56. }
  57. private:
  58. QuickTimeMovieComponent qtComp;
  59. FilenameComponent fileChooser;
  60. };
  61. //==============================================================================
  62. class QuickTimeDemo : public Component
  63. {
  64. public:
  65. //==============================================================================
  66. QuickTimeDemo()
  67. {
  68. setName ("QuickTime");
  69. // add a movie component..
  70. addAndMakeVisible (&qtComp1);
  71. addAndMakeVisible (&qtComp2);
  72. }
  73. ~QuickTimeDemo()
  74. {
  75. qtComp1.setVisible (false);
  76. qtComp2.setVisible (false);
  77. }
  78. void resized()
  79. {
  80. qtComp1.setBoundsRelative (0.05f, 0.05f, 0.425f, 0.9f);
  81. qtComp2.setBoundsRelative (0.525f, 0.05f, 0.425f, 0.9f);
  82. }
  83. private:
  84. //==============================================================================
  85. QuickTimeWindowWithFileBrowser qtComp1, qtComp2;
  86. };
  87. //==============================================================================
  88. Component* createQuickTimeDemo()
  89. {
  90. return new QuickTimeDemo();
  91. }
  92. #endif