2 #include "../jucedemo_headers.h"
6 //==============================================================================
7 class DirectShowWindowWithFileBrowser
: public Component
,
8 public FilenameComponentListener
11 DirectShowWindowWithFileBrowser (DirectShowComponent::VideoRendererType type
)
12 : fileChooser ("movie", File::nonexistent
, true, false, false,
13 "*", String::empty
, "(choose a video file to play)"),
16 addAndMakeVisible (&dshowComp
);
17 addAndMakeVisible (&fileChooser
);
18 fileChooser
.addListener (this);
19 fileChooser
.setBrowseButtonText ("browse");
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
));
44 AlertWindow::showMessageBox (AlertWindow::WarningIcon
,
45 "Couldn't load the file!",
46 "Sorry, DirectShow didn't manage to load that file!");
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
,
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())
87 void sliderValueChanged (Slider
* sliderThatWasMoved
)
89 dshowComp
.setPosition (position
.getValue());
94 const int playButtonWidth
= 90;
95 playButton
.setBounds (0, 0, playButtonWidth
, getHeight());
96 position
.setBounds (playButtonWidth
, 0, getWidth() - playButtonWidth
, getHeight());
101 if (! position
.isMouseButtonDown())
102 position
.setValue (dshowComp
.getPosition(), false);
106 TextButton playButton
;
108 DirectShowComponent
& dshowComp
;
111 ScopedPointer
<TransportControl
> transportControl
;
115 //==============================================================================
116 class DirectShowDemo
: public Component
119 //==============================================================================
121 : dsComp1 (DirectShowComponent::dshowVMR7
),
122 dsComp2 (DirectShowComponent::dshowEVR
)
124 setName ("DirectShow");
126 // add a movie component..
127 addAndMakeVisible (&dsComp1
);
128 addAndMakeVisible (&dsComp2
);
133 dsComp1
.setVisible (false);
134 dsComp2
.setVisible (false);
139 dsComp1
.setBoundsRelative (0.05f
, 0.05f
, 0.425f
, 0.9f
);
140 dsComp2
.setBoundsRelative (0.525f
, 0.05f
, 0.425f
, 0.9f
);
144 //==============================================================================
145 DirectShowWindowWithFileBrowser dsComp1
, dsComp2
;
149 //==============================================================================
150 Component
* createDirectShowDemo()
152 return new DirectShowDemo();