mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-14 00:14:18 +00:00
Added Animated App template and examples
This commit is contained in:
parent
fefcf7aca6
commit
ff6520a89a
1141 changed files with 438491 additions and 94 deletions
|
|
@ -0,0 +1,216 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2013 - Raw Material Software Ltd.
|
||||
|
||||
Permission is granted to use this software under the terms of either:
|
||||
a) the GPL v2 (or any later version)
|
||||
b) the Affero GPL v3
|
||||
|
||||
Details of these licenses can be found at: www.gnu.org/licenses
|
||||
|
||||
JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
To release a closed-source product which uses JUCE, commercial licenses are
|
||||
available: visit www.juce.com for more information.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#ifndef JUCE_DIRECTSHOWCOMPONENT_H_INCLUDED
|
||||
#define JUCE_DIRECTSHOWCOMPONENT_H_INCLUDED
|
||||
|
||||
#if JUCE_DIRECTSHOW || DOXYGEN
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
A window that can play back a DirectShow video.
|
||||
|
||||
@note Controller is not implemented
|
||||
*/
|
||||
class JUCE_API DirectShowComponent : public Component
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
/** DirectShow video renderer type.
|
||||
|
||||
See MSDN for advice about choosing the right renderer.
|
||||
*/
|
||||
enum VideoRendererType
|
||||
{
|
||||
dshowDefault, /**< VMR7 for Windows XP, EVR for Windows Vista and later */
|
||||
dshowVMR7, /**< Video Mixing Renderer 7 */
|
||||
dshowEVR /**< Enhanced Video Renderer */
|
||||
};
|
||||
|
||||
/** Creates a DirectShowComponent, initially blank.
|
||||
|
||||
Use the loadMovie() method to load a video once you've added the
|
||||
component to a window, (or put it on the desktop as a heavyweight window).
|
||||
Loading a video when the component isn't visible can cause problems, as
|
||||
DirectShow needs a window handle to initialise properly.
|
||||
|
||||
@see VideoRendererType
|
||||
*/
|
||||
DirectShowComponent (VideoRendererType type = dshowDefault);
|
||||
|
||||
/** Destructor. */
|
||||
~DirectShowComponent();
|
||||
|
||||
/** Returns true if DirectShow is installed and working on this machine. */
|
||||
static bool isDirectShowAvailable();
|
||||
|
||||
//==============================================================================
|
||||
/** Tries to load a DirectShow video from a file or URL into the player.
|
||||
|
||||
It's best to call this function once you've added the component to a window,
|
||||
(or put it on the desktop as a heavyweight window). Loading a video when the
|
||||
component isn't visible can cause problems, because DirectShow needs a window
|
||||
handle to do its stuff.
|
||||
|
||||
@param fileOrURLPath the file or URL path to open
|
||||
@returns true if the video opens successfully
|
||||
*/
|
||||
bool loadMovie (const String& fileOrURLPath);
|
||||
|
||||
/** Tries to load a DirectShow video from a file into the player.
|
||||
|
||||
It's best to call this function once you've added the component to a window,
|
||||
(or put it on the desktop as a heavyweight window). Loading a video when the
|
||||
component isn't visible can cause problems, because DirectShow needs a window
|
||||
handle to do its stuff.
|
||||
|
||||
@param videoFile the video file to open
|
||||
@returns true if the video opens successfully
|
||||
*/
|
||||
bool loadMovie (const File& videoFile);
|
||||
|
||||
/** Tries to load a DirectShow video from a URL into the player.
|
||||
|
||||
It's best to call this function once you've added the component to a window,
|
||||
(or put it on the desktop as a heavyweight window). Loading a video when the
|
||||
component isn't visible can cause problems, because DirectShow needs a window
|
||||
handle to do its stuff.
|
||||
|
||||
@param videoURL the video URL to open
|
||||
@returns true if the video opens successfully
|
||||
*/
|
||||
bool loadMovie (const URL& videoURL);
|
||||
|
||||
/** Closes the video, if one is open. */
|
||||
void closeMovie();
|
||||
|
||||
/** Returns the file path or URL from which the video file was loaded.
|
||||
If there isn't one, this returns an empty string.
|
||||
*/
|
||||
File getCurrentMoviePath() const;
|
||||
|
||||
/** Returns true if there's currently a video open. */
|
||||
bool isMovieOpen() const;
|
||||
|
||||
/** Returns the length of the video, in seconds. */
|
||||
double getMovieDuration() const;
|
||||
|
||||
/** Returns the video's natural size, in pixels.
|
||||
|
||||
You can use this to resize the component to show the video at its preferred
|
||||
scale.
|
||||
|
||||
If no video is loaded, the size returned will be 0 x 0.
|
||||
*/
|
||||
void getMovieNormalSize (int& width, int& height) const;
|
||||
|
||||
/** This will position the component within a given area, keeping its aspect
|
||||
ratio correct according to the video's normal size.
|
||||
|
||||
The component will be made as large as it can go within the space, and will
|
||||
be aligned according to the justification value if this means there are gaps at
|
||||
the top or sides.
|
||||
|
||||
@note Not implemented
|
||||
*/
|
||||
void setBoundsWithCorrectAspectRatio (const Rectangle<int>& spaceToFitWithin,
|
||||
RectanglePlacement placement);
|
||||
|
||||
/** Starts the video playing. */
|
||||
void play();
|
||||
|
||||
/** Stops the video playing. */
|
||||
void stop();
|
||||
|
||||
/** Returns true if the video is currently playing. */
|
||||
bool isPlaying() const;
|
||||
|
||||
/** Moves the video's position back to the start. */
|
||||
void goToStart();
|
||||
|
||||
/** Sets the video's position to a given time. */
|
||||
void setPosition (double seconds);
|
||||
|
||||
/** Returns the current play position of the video. */
|
||||
double getPosition() const;
|
||||
|
||||
/** Changes the video playback rate.
|
||||
|
||||
A value of 1 is normal speed, greater values play it proportionately faster,
|
||||
smaller values play it slower.
|
||||
*/
|
||||
void setSpeed (float newSpeed);
|
||||
|
||||
/** Changes the video's playback volume.
|
||||
|
||||
@param newVolume the volume in the range 0 (silent) to 1.0 (full)
|
||||
*/
|
||||
void setMovieVolume (float newVolume);
|
||||
|
||||
/** Returns the video's playback volume.
|
||||
|
||||
@returns the volume in the range 0 (silent) to 1.0 (full)
|
||||
*/
|
||||
float getMovieVolume() const;
|
||||
|
||||
/** Tells the video whether it should loop. */
|
||||
void setLooping (bool shouldLoop);
|
||||
|
||||
/** Returns true if the video is currently looping.
|
||||
|
||||
@see setLooping
|
||||
*/
|
||||
bool isLooping() const;
|
||||
|
||||
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
void paint (Graphics&) override;
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
String videoPath;
|
||||
bool videoLoaded, looping;
|
||||
|
||||
class DirectShowContext;
|
||||
friend class DirectShowContext;
|
||||
friend struct ContainerDeletePolicy<DirectShowContext>;
|
||||
ScopedPointer<DirectShowContext> context;
|
||||
|
||||
class DirectShowComponentWatcher;
|
||||
friend class DirectShowComponentWatcher;
|
||||
friend struct ContainerDeletePolicy<DirectShowComponentWatcher>;
|
||||
ScopedPointer<DirectShowComponentWatcher> componentWatcher;
|
||||
|
||||
//==============================================================================
|
||||
void updateContextPosition();
|
||||
void showContext (bool shouldBeVisible);
|
||||
void recreateNativeWindowAsync();
|
||||
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DirectShowComponent)
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // JUCE_DIRECTSHOWCOMPONENT_H_INCLUDED
|
||||
|
|
@ -0,0 +1,220 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2013 - Raw Material Software Ltd.
|
||||
|
||||
Permission is granted to use this software under the terms of either:
|
||||
a) the GPL v2 (or any later version)
|
||||
b) the Affero GPL v3
|
||||
|
||||
Details of these licenses can be found at: www.gnu.org/licenses
|
||||
|
||||
JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
To release a closed-source product which uses JUCE, commercial licenses are
|
||||
available: visit www.juce.com for more information.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#ifndef JUCE_QUICKTIMEMOVIECOMPONENT_H_INCLUDED
|
||||
#define JUCE_QUICKTIMEMOVIECOMPONENT_H_INCLUDED
|
||||
|
||||
// (NB: This stuff mustn't go inside the "#if QUICKTIME" block, or it'll break the
|
||||
// amalgamated build)
|
||||
#ifndef DOXYGEN
|
||||
#if JUCE_WINDOWS
|
||||
typedef ActiveXControlComponent QTCompBaseClass;
|
||||
#elif JUCE_MAC
|
||||
typedef NSViewComponent QTCompBaseClass;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if JUCE_QUICKTIME || DOXYGEN
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
A window that can play back a QuickTime movie.
|
||||
|
||||
*/
|
||||
class JUCE_API QuickTimeMovieComponent : public QTCompBaseClass
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
/** Creates a QuickTimeMovieComponent, initially blank.
|
||||
|
||||
Use the loadMovie() method to load a movie once you've added the
|
||||
component to a window, (or put it on the desktop as a heavyweight window).
|
||||
Loading a movie when the component isn't visible can cause problems, as
|
||||
QuickTime needs a window handle to initialise properly.
|
||||
*/
|
||||
QuickTimeMovieComponent();
|
||||
|
||||
/** Destructor. */
|
||||
~QuickTimeMovieComponent();
|
||||
|
||||
/** Returns true if QT is installed and working on this machine.
|
||||
*/
|
||||
static bool isQuickTimeAvailable() noexcept;
|
||||
|
||||
//==============================================================================
|
||||
/** Tries to load a QuickTime movie from a file into the player.
|
||||
|
||||
It's best to call this function once you've added the component to a window,
|
||||
(or put it on the desktop as a heavyweight window). Loading a movie when the
|
||||
component isn't visible can cause problems, because QuickTime needs a window
|
||||
handle to do its stuff.
|
||||
|
||||
@param movieFile the .mov file to open
|
||||
@param isControllerVisible whether to show a controller bar at the bottom
|
||||
@returns true if the movie opens successfully
|
||||
*/
|
||||
bool loadMovie (const File& movieFile,
|
||||
bool isControllerVisible);
|
||||
|
||||
/** Tries to load a QuickTime movie from a URL into the player.
|
||||
|
||||
It's best to call this function once you've added the component to a window,
|
||||
(or put it on the desktop as a heavyweight window). Loading a movie when the
|
||||
component isn't visible can cause problems, because QuickTime needs a window
|
||||
handle to do its stuff.
|
||||
|
||||
@param movieURL the .mov file to open
|
||||
@param isControllerVisible whether to show a controller bar at the bottom
|
||||
@returns true if the movie opens successfully
|
||||
*/
|
||||
bool loadMovie (const URL& movieURL,
|
||||
bool isControllerVisible);
|
||||
|
||||
/** Tries to load a QuickTime movie from a stream into the player.
|
||||
|
||||
It's best to call this function once you've added the component to a window,
|
||||
(or put it on the desktop as a heavyweight window). Loading a movie when the
|
||||
component isn't visible can cause problems, because QuickTime needs a window
|
||||
handle to do its stuff.
|
||||
|
||||
@param movieStream a stream containing a .mov file. The component may try
|
||||
to read the whole stream before playing, rather than
|
||||
streaming from it.
|
||||
@param isControllerVisible whether to show a controller bar at the bottom
|
||||
@returns true if the movie opens successfully
|
||||
*/
|
||||
bool loadMovie (InputStream* movieStream,
|
||||
bool isControllerVisible);
|
||||
|
||||
/** Closes the movie, if one is open. */
|
||||
void closeMovie();
|
||||
|
||||
/** Returns the movie file that is currently open.
|
||||
|
||||
If there isn't one, this returns File::nonexistent
|
||||
*/
|
||||
File getCurrentMovieFile() const;
|
||||
|
||||
/** Returns true if there's currently a movie open. */
|
||||
bool isMovieOpen() const;
|
||||
|
||||
/** Returns the length of the movie, in seconds. */
|
||||
double getMovieDuration() const;
|
||||
|
||||
/** Returns the movie's natural size, in pixels.
|
||||
|
||||
You can use this to resize the component to show the movie at its preferred
|
||||
scale.
|
||||
|
||||
If no movie is loaded, the size returned will be 0 x 0.
|
||||
*/
|
||||
void getMovieNormalSize (int& width, int& height) const;
|
||||
|
||||
/** This will position the component within a given area, keeping its aspect
|
||||
ratio correct according to the movie's normal size.
|
||||
|
||||
The component will be made as large as it can go within the space, and will
|
||||
be aligned according to the justification value if this means there are gaps at
|
||||
the top or sides.
|
||||
*/
|
||||
void setBoundsWithCorrectAspectRatio (const Rectangle<int>& spaceToFitWithin,
|
||||
RectanglePlacement placement);
|
||||
|
||||
/** Starts the movie playing. */
|
||||
void play();
|
||||
|
||||
/** Stops the movie playing. */
|
||||
void stop();
|
||||
|
||||
/** Returns true if the movie is currently playing. */
|
||||
bool isPlaying() const;
|
||||
|
||||
/** Moves the movie's position back to the start. */
|
||||
void goToStart();
|
||||
|
||||
/** Sets the movie's position to a given time. */
|
||||
void setPosition (double seconds);
|
||||
|
||||
/** Returns the current play position of the movie. */
|
||||
double getPosition() const;
|
||||
|
||||
/** Changes the movie playback rate.
|
||||
|
||||
A value of 1 is normal speed, greater values play it proportionately faster,
|
||||
smaller values play it slower.
|
||||
*/
|
||||
void setSpeed (float newSpeed);
|
||||
|
||||
/** Changes the movie's playback volume.
|
||||
@param newVolume the volume in the range 0 (silent) to 1.0 (full)
|
||||
*/
|
||||
void setMovieVolume (float newVolume);
|
||||
|
||||
/** Returns the movie's playback volume.
|
||||
@returns the volume in the range 0 (silent) to 1.0 (full)
|
||||
*/
|
||||
float getMovieVolume() const;
|
||||
|
||||
/** Tells the movie whether it should loop. */
|
||||
void setLooping (bool shouldLoop);
|
||||
|
||||
/** Returns true if the movie is currently looping.
|
||||
@see setLooping
|
||||
*/
|
||||
bool isLooping() const;
|
||||
|
||||
/** True if the native QuickTime controller bar is shown in the window.
|
||||
@see loadMovie
|
||||
*/
|
||||
bool isControllerVisible() const;
|
||||
|
||||
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
void paint (Graphics&) override;
|
||||
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
File movieFile;
|
||||
bool movieLoaded, controllerVisible, looping;
|
||||
|
||||
#if JUCE_WINDOWS
|
||||
void parentHierarchyChanged() override;
|
||||
void visibilityChanged() override;
|
||||
void createControlIfNeeded();
|
||||
bool isControlCreated() const;
|
||||
|
||||
class Pimpl;
|
||||
friend struct ContainerDeletePolicy<Pimpl>;
|
||||
ScopedPointer<Pimpl> pimpl;
|
||||
#else
|
||||
void* movie;
|
||||
#endif
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (QuickTimeMovieComponent)
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // JUCE_QUICKTIMEMOVIECOMPONENT_H_INCLUDED
|
||||
Loading…
Add table
Add a link
Reference in a new issue