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.

119 lines
3.8KB

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