Main.cpp
*/
//#include "juce_amalgamated.h"
#include "MainComponent.h"
//#include "propuestas/ventanas.h"
//==============================================================================
/**
This is the top-level window that we'll pop up. Inside it, we'll create and
show a component from the MainComponent.cpp file (you can open this file using
the Jucer to edit it).
*/
class YCCFormApp : public DocumentWindow
{
public:
//==============================================================================
YCCFormApp()
: DocumentWindow (T("VideoPlayer"),
Colours::lightgrey,
DocumentWindow::allButtons,
true)
{
// Create an instance of our main content component, and add it
// to our window.
MainComponent* const contentComponent = new MainComponent();
setContentComponent(contentComponent);
//setResizable(true,true);
centreWithSize (getWidth(), getHeight());
setVisible (true);
}
~YCCFormApp()
{
// (the content component will be deleted automatically, so no need to do it here)
}
//==============================================================================
void closeButtonPressed()
{
// When the user presses the close button, we'll tell the app to quit. This
// window will be deleted by our HelloWorldApplication::shutdown() method
//
JUCEApplication::quit();
}
};
//==============================================================================
/** This is the application object that is started up when Juce starts. It handles
the initialisation and shutdown of the whole application.
*/
class YCCJUCEApplication : public JUCEApplication
{
/* Important! NEVER embed objects directly inside your JUCEApplication class! Use
ONLY pointers to objects, which you should create during the initialise() method
(NOT in the constructor!) and delete in the shutdown() method (NOT in the
destructor!)
This is because the application object gets created before Juce has been properly
initialised, so any embedded objects would also get constructed too soon.
*/
YCCFormApp* yccFormApp;
public:
//==============================================================================
YCCJUCEApplication()
: yccFormApp (0)
{
// NEVER do anything in here that could involve any Juce function being called
// - leave all your startup tasks until the initialise() method.
}
~YCCJUCEApplication()
{
// Your shutdown() method should already have done all the things necessary to
// clean up this app object, so you should never need to put anything in
// the destructor.
// Making any Juce calls in here could be very dangerous...
}
//==============================================================================
void initialise (const String& commandLine)
{
// just create the main window...
yccFormApp = new YCCFormApp();
yccFormApp->setBounds(100,100,800,600);
/* ..and now return, which will fall into to the main event
dispatch loop, and this will run until something calls
JUCEAppliction::quit().
In this case, JUCEAppliction::quit() will be called by the
hello world window being clicked.
*/
}
void shutdown()
{
// clear up..
if (yccFormApp != 0)
delete yccFormApp;
}
//==============================================================================
const String getApplicationName()
{
return T("VideoPlayer");
}
const String getApplicationVersion()
{
return T("1.0");
}
bool moreThanOneInstanceAllowed()
{
return true;
}
void anotherInstanceStarted (const String& commandLine)
{
}
};
//==============================================================================
// This macro creates the application's main() function..
START_JUCE_APPLICATION (YCCJUCEApplication)
MainComponent.h
/*
==============================================================================
This is an automatically generated file created by the Jucer!
Creation date: 29 Mar 2010 2:19:21 pm
Be careful when adding custom code to these files, as only the code within
the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
and re-saved.
Jucer version: 1.11
------------------------------------------------------------------------------
The Jucer is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-6 by Raw Material Software ltd.
==============================================================================
*/
#ifndef __JUCER_HEADER_MAINCOMPONENT_MAINCOMPONENT_E426AA9D__
#define __JUCER_HEADER_MAINCOMPONENT_MAINCOMPONENT_E426AA9D__
//[Headers] -- You can add your own extra header files here --
#include "juce.h"
//[/Headers]
#include "VideoVLC.h"
//==============================================================================
/**
//[Comments]
An auto-generated component, created by the Jucer.
Describe your class and how it works here!
//[/Comments]
*/
class MainComponent : public Component,
public ButtonListener
{
public:
//==============================================================================
MainComponent ();
~MainComponent();
//==============================================================================
//[UserMethods] -- You can add your own custom methods in this section.
//[/UserMethods]
void paint (Graphics& g);
void resized();
void buttonClicked (Button* buttonThatWasClicked);
//==============================================================================
juce_UseDebuggingNewOperator
private:
//[UserVariables] -- You can add your own custom variables in this section.
//[/UserVariables]
//==============================================================================
TextButton* btnplay;
VideoVLC* videoVLC;
TextButton* btnstop;
TextButton* btnpause;
TextButton* btnload;
//==============================================================================
// (prevent copy constructor and operator= being generated..)
MainComponent (const MainComponent&);
const MainComponent& operator= (const MainComponent&);
};
#endif // __JUCER_HEADER_MAINCOMPONENT_MAINCOMPONENT_E426AA9D__
MainComponent.cpp
#include "MainComponent.h"
//[MiscUserDefs] You can add your own user definitions and misc code here...
//[/MiscUserDefs]
//==============================================================================
MainComponent::MainComponent ()
: Component (T("MainComponent")),
btnplay (0),
videoVLC (0),
btnstop (0),
btnpause (0),
btnload (0)
{
addAndMakeVisible (btnplay = new TextButton (T("new button")));
btnplay->setButtonText (T("play"));
btnplay->addButtonListener (this);
addAndMakeVisible (videoVLC = new VideoVLC());
addAndMakeVisible (btnstop = new TextButton (T("new button")));
btnstop->setButtonText (T("stop"));
btnstop->addButtonListener (this);
addAndMakeVisible (btnpause = new TextButton (T("new button")));
btnpause->setButtonText (T("pause"));
btnpause->addButtonListener (this);
addAndMakeVisible (btnload = new TextButton (T("btnload")));
btnload->setButtonText (T("Load media"));
btnload->addButtonListener (this);
//[UserPreSize]
//[/UserPreSize]
setSize (200, 200);
//[Constructor] You can add your own custom stuff here..
//[/Constructor]
}
MainComponent::~MainComponent()
{
//[Destructor_pre]. You can add your own custom destruction code here..
//[/Destructor_pre]
deleteAndZero (btnplay);
deleteAndZero (videoVLC);
deleteAndZero (btnstop);
deleteAndZero (btnpause);
deleteAndZero (btnload);
//[Destructor]. You can add your own custom destruction code here..
//[/Destructor]
}
//==============================================================================
void MainComponent::paint (Graphics& g)
{
//[UserPrePaint] Add your own custom painting code here..
//[/UserPrePaint]
g.fillAll (Colour (0xff6e7071));
//[UserPaint] Add your own custom painting code here..
//[/UserPaint]
}
void MainComponent::resized()
{
btnplay->setBounds (16, 264, 48, 24);
videoVLC->setBounds (16, 16, 312, 240);
btnstop->setBounds (72, 264, 48, 24);
btnpause->setBounds (128, 264, 48, 24);
btnload->setBounds (248, 264, 80, 24);
//[UserResized] Add your own custom resize handling here..
//[/UserResized]
}
void MainComponent::buttonClicked (Button* buttonThatWasClicked)
{
//[UserbuttonClicked_Pre]
//[/UserbuttonClicked_Pre]
if (buttonThatWasClicked == btnplay)
{
//[UserButtonCode_btnplay] -- add your button handler code here..
videoVLC->play();
//[/UserButtonCode_btnplay]
}
else if (buttonThatWasClicked == btnstop)
{
//[UserButtonCode_btnstop] -- add your button handler code here..
videoVLC->stop();
//[/UserButtonCode_btnstop]
}
else if (buttonThatWasClicked == btnpause)
{
//[UserButtonCode_btnpause] -- add your button handler code here..
videoVLC->pause();
//[/UserButtonCode_btnpause]
}
else if (buttonThatWasClicked == btnload)
{
//[UserButtonCode_btnload] -- add your button handler code here..
FileChooser fc (T("Seleccione el archivo de video o audio.."),
File::getCurrentWorkingDirectory(),
T("*.*"),false);
if (fc.browseForFileToOpen()) {
File selectFile = fc.getResult();
videoVLC->loadMedia(selectFile.getFullPathName());
}
//[/UserButtonCode_btnload]
}
//[UserbuttonClicked_Post]
//[/UserbuttonClicked_Post]
}