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.

124 lines
4.3KB

  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. {
  28. addAndMakeVisible (qtComp = new QuickTimeMovieComponent());
  29. // and a file-chooser..
  30. addAndMakeVisible (fileChooser = new FilenameComponent (T("movie"),
  31. File::nonexistent,
  32. true, false, false,
  33. T("*.*"),
  34. String::empty,
  35. T("(choose a video file to play)")));
  36. fileChooser->addListener (this);
  37. fileChooser->setBrowseButtonText (T("browse"));
  38. }
  39. ~QuickTimeWindowWithFileBrowser()
  40. {
  41. deleteAllChildren();
  42. }
  43. void resized()
  44. {
  45. qtComp->setBounds (0, 0, getWidth(), getHeight() - 30);
  46. fileChooser->setBounds (0, getHeight() - 24, getWidth(), 24);
  47. }
  48. void filenameComponentChanged (FilenameComponent*)
  49. {
  50. // this is called when the user changes the filename in the file chooser box
  51. if (qtComp->loadMovie (fileChooser->getCurrentFile(), true))
  52. {
  53. // loaded the file ok, so let's start it playing..
  54. qtComp->play();
  55. }
  56. else
  57. {
  58. AlertWindow::showMessageBox (AlertWindow::WarningIcon,
  59. T("Couldn't load the file!"),
  60. T("Sorry, QuickTime didn't manage to load that file!"));
  61. }
  62. }
  63. private:
  64. QuickTimeMovieComponent* qtComp;
  65. FilenameComponent* fileChooser;
  66. };
  67. //==============================================================================
  68. class QuickTimeDemo : public Component
  69. {
  70. public:
  71. //==============================================================================
  72. QuickTimeDemo()
  73. {
  74. setName (T("QuickTime"));
  75. // add a movie component..
  76. addAndMakeVisible (qtComp1 = new QuickTimeWindowWithFileBrowser());
  77. addAndMakeVisible (qtComp2 = new QuickTimeWindowWithFileBrowser());
  78. }
  79. ~QuickTimeDemo()
  80. {
  81. deleteAllChildren();
  82. }
  83. void resized()
  84. {
  85. qtComp1->setBoundsRelative (0.05f, 0.05f, 0.425f, 0.9f);
  86. qtComp2->setBoundsRelative (0.525f, 0.05f, 0.425f, 0.9f);
  87. }
  88. private:
  89. //==============================================================================
  90. QuickTimeWindowWithFileBrowser* qtComp1;
  91. QuickTimeWindowWithFileBrowser* qtComp2;
  92. };
  93. //==============================================================================
  94. Component* createQuickTimeDemo()
  95. {
  96. return new QuickTimeDemo();
  97. }
  98. #endif