Add TAL-Reverb-II plugin to test
[juce-lv2.git] / juce / source / extras / JuceDemo / Source / demos / DirectShowDemo.cpp
bloba7de04f553f7b99218686322f868dad8b02c2150
2 #include "../jucedemo_headers.h"
4 #if JUCE_DIRECTSHOW
6 //==============================================================================
7 class DirectShowWindowWithFileBrowser : public Component,
8 public FilenameComponentListener
10 public:
11 DirectShowWindowWithFileBrowser (DirectShowComponent::VideoRendererType type)
12 : fileChooser ("movie", File::nonexistent, true, false, false,
13 "*", String::empty, "(choose a video file to play)"),
14 dshowComp (type)
16 addAndMakeVisible (&dshowComp);
17 addAndMakeVisible (&fileChooser);
18 fileChooser.addListener (this);
19 fileChooser.setBrowseButtonText ("browse");
22 void resized()
24 dshowComp.setBounds (0, 0, getWidth(), getHeight() - 60);
26 if (transportControl != 0)
27 transportControl->setBounds (0, dshowComp.getBottom() + 4, getWidth(), 26);
29 fileChooser.setBounds (0, getHeight() - 24, getWidth(), 24);
32 void filenameComponentChanged (FilenameComponent*)
34 // this is called when the user changes the filename in the file chooser box
35 if (dshowComp.loadMovie (fileChooser.getCurrentFile()))
37 addAndMakeVisible (transportControl = new TransportControl (dshowComp));
38 resized();
40 dshowComp.play();
42 else
44 AlertWindow::showMessageBox (AlertWindow::WarningIcon,
45 "Couldn't load the file!",
46 "Sorry, DirectShow didn't manage to load that file!");
50 private:
51 DirectShowComponent dshowComp;
52 FilenameComponent fileChooser;
54 //==============================================================================
55 // A quick-and-dirty transport control, containing a play button and a position slider..
56 class TransportControl : public Component,
57 public ButtonListener,
58 public SliderListener,
59 public Timer
61 public:
62 TransportControl (DirectShowComponent& dshowComp_)
63 : playButton ("Play/Pause"),
64 position (String::empty),
65 dshowComp (dshowComp_)
67 addAndMakeVisible (&playButton);
68 playButton.addListener (this);
70 addAndMakeVisible (&position);
71 position.setRange (0, dshowComp.getMovieDuration(), 0);
72 position.setSliderStyle (Slider::LinearHorizontal);
73 position.setTextBoxStyle (Slider::NoTextBox, false, 80, 20);
74 position.addListener (this);
76 startTimer (1000 / 50);
79 void buttonClicked (Button* buttonThatWasClicked)
81 if (dshowComp.isPlaying())
82 dshowComp.stop();
83 else
84 dshowComp.play();
87 void sliderValueChanged (Slider* sliderThatWasMoved)
89 dshowComp.setPosition (position.getValue());
92 void resized()
94 const int playButtonWidth = 90;
95 playButton.setBounds (0, 0, playButtonWidth, getHeight());
96 position.setBounds (playButtonWidth, 0, getWidth() - playButtonWidth, getHeight());
99 void timerCallback()
101 if (! position.isMouseButtonDown())
102 position.setValue (dshowComp.getPosition(), false);
105 private:
106 TextButton playButton;
107 Slider position;
108 DirectShowComponent& dshowComp;
111 ScopedPointer<TransportControl> transportControl;
115 //==============================================================================
116 class DirectShowDemo : public Component
118 public:
119 //==============================================================================
120 DirectShowDemo()
121 : dsComp1 (DirectShowComponent::dshowVMR7),
122 dsComp2 (DirectShowComponent::dshowEVR)
124 setName ("DirectShow");
126 // add a movie component..
127 addAndMakeVisible (&dsComp1);
128 addAndMakeVisible (&dsComp2);
131 ~DirectShowDemo()
133 dsComp1.setVisible (false);
134 dsComp2.setVisible (false);
137 void resized()
139 dsComp1.setBoundsRelative (0.05f, 0.05f, 0.425f, 0.9f);
140 dsComp2.setBoundsRelative (0.525f, 0.05f, 0.425f, 0.9f);
143 private:
144 //==============================================================================
145 DirectShowWindowWithFileBrowser dsComp1, dsComp2;
149 //==============================================================================
150 Component* createDirectShowDemo()
152 return new DirectShowDemo();
155 #endif