diff options
Diffstat (limited to 'avmedia/source/viewer')
-rw-r--r-- | avmedia/source/viewer/makefile.mk | 57 | ||||
-rw-r--r-- | avmedia/source/viewer/mediaevent_impl.cxx | 223 | ||||
-rw-r--r-- | avmedia/source/viewer/mediaevent_impl.hxx | 89 | ||||
-rw-r--r-- | avmedia/source/viewer/mediawindow.cxx | 580 | ||||
-rw-r--r-- | avmedia/source/viewer/mediawindow.hrc | 9 | ||||
-rw-r--r-- | avmedia/source/viewer/mediawindow.src | 77 | ||||
-rw-r--r-- | avmedia/source/viewer/mediawindow_impl.cxx | 546 | ||||
-rw-r--r-- | avmedia/source/viewer/mediawindow_impl.hxx | 145 | ||||
-rw-r--r-- | avmedia/source/viewer/mediawindowbase_impl.cxx | 442 | ||||
-rw-r--r-- | avmedia/source/viewer/mediawindowbase_impl.hxx | 131 |
10 files changed, 2299 insertions, 0 deletions
diff --git a/avmedia/source/viewer/makefile.mk b/avmedia/source/viewer/makefile.mk new file mode 100644 index 000000000000..8d5d6a5df52d --- /dev/null +++ b/avmedia/source/viewer/makefile.mk @@ -0,0 +1,57 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/.. +PRJNAME=avmedia +TARGET=viewer + +# --- Settings ---------------------------------- + +.INCLUDE : settings.mk + +# --- Resources --------------------------------- + +SRS1NAME=$(TARGET) +SRC1FILES =\ + mediawindow.src + +# --- Files ------------------------------------- + +SLOFILES= \ + $(SLO)$/mediaevent_impl.obj \ + $(SLO)$/mediawindowbase_impl.obj \ + $(SLO)$/mediawindow_impl.obj \ + $(SLO)$/mediawindow.obj + +EXCEPTIONSFILES= \ + $(SLO)$/mediawindow.obj \ + $(SLO)$/mediawindowbase_impl.obj \ + $(SLO)$/mediawindow_impl.obj + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk diff --git a/avmedia/source/viewer/mediaevent_impl.cxx b/avmedia/source/viewer/mediaevent_impl.cxx new file mode 100644 index 000000000000..cf86f54df8f9 --- /dev/null +++ b/avmedia/source/viewer/mediaevent_impl.cxx @@ -0,0 +1,223 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "mediaevent_impl.hxx" +#include "mediawindow_impl.hxx" +#include <osl/mutex.hxx> +#include <vos/mutex.hxx> +#include <vcl/svapp.hxx> +#include <vcl/event.hxx> + +using namespace ::com::sun::star; + +/* Definition of MediaWindowImpl class */ + +namespace avmedia { namespace priv { +// --------------------------- +// - MediaEventListenersImpl - +// --------------------------- + +MediaEventListenersImpl::MediaEventListenersImpl( Window& rEventWindow ) : + mpNotifyWindow( &rEventWindow ) +{ +} + +// --------------------------------------------------------------------- + +MediaEventListenersImpl::~MediaEventListenersImpl() +{ +} + +// --------------------------------------------------------------------- + +void MediaEventListenersImpl::cleanUp() +{ + Application::RemoveMouseAndKeyEvents( reinterpret_cast< ::Window* >( mpNotifyWindow ) ); + mpNotifyWindow = NULL; +} + +// --------------------------------------------------------------------- + +void SAL_CALL MediaEventListenersImpl::disposing( const ::com::sun::star::lang::EventObject& /* Source */ ) + throw (::com::sun::star::uno::RuntimeException) +{ +} + +// --------------------------------------------------------------------- + +void SAL_CALL MediaEventListenersImpl::keyPressed( const ::com::sun::star::awt::KeyEvent& e ) + throw (::com::sun::star::uno::RuntimeException) +{ + const ::osl::MutexGuard aGuard( maMutex ); + const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); + + if( mpNotifyWindow ) + { + KeyCode aVCLKeyCode( e.KeyCode, + ( ( e.Modifiers & 1 ) ? KEY_SHIFT : 0 ) | + ( ( e.Modifiers & 2 ) ? KEY_MOD1 : 0 ) | + ( ( e.Modifiers & 4 ) ? KEY_MOD2 : 0 ) ); + KeyEvent aVCLKeyEvt( e.KeyChar, aVCLKeyCode ); + + Application::PostKeyEvent( VCLEVENT_WINDOW_KEYINPUT, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLKeyEvt ); + } +} + +// --------------------------------------------------------------------- + +void SAL_CALL MediaEventListenersImpl::keyReleased( const ::com::sun::star::awt::KeyEvent& e ) + throw (::com::sun::star::uno::RuntimeException) +{ + const ::osl::MutexGuard aGuard( maMutex ); + const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); + + if( mpNotifyWindow ) + { + KeyCode aVCLKeyCode( e.KeyCode, + ( ( e.Modifiers & 1 ) ? KEY_SHIFT : 0 ) | + ( ( e.Modifiers & 2 ) ? KEY_MOD1 : 0 ) | + ( ( e.Modifiers & 4 ) ? KEY_MOD2 : 0 ) ); + KeyEvent aVCLKeyEvt( e.KeyChar, aVCLKeyCode ); + Application::PostKeyEvent( VCLEVENT_WINDOW_KEYUP, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLKeyEvt ); + } +} + +// --------------------------------------------------------------------- + +void SAL_CALL MediaEventListenersImpl::mousePressed( const ::com::sun::star::awt::MouseEvent& e ) + throw (::com::sun::star::uno::RuntimeException) +{ + const ::osl::MutexGuard aGuard( maMutex ); + const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); + + if( mpNotifyWindow ) + { + MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), + sal::static_int_cast< USHORT >(e.ClickCount), + 0, + ( ( e.Buttons & 1 ) ? MOUSE_LEFT : 0 ) | + ( ( e.Buttons & 2 ) ? MOUSE_RIGHT : 0 ) | + ( ( e.Buttons & 4 ) ? MOUSE_MIDDLE : 0 ), + e.Modifiers ); + Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt ); + } +} + +// ----------------------------------------------gvd----------------------- + +void SAL_CALL MediaEventListenersImpl::mouseReleased( const ::com::sun::star::awt::MouseEvent& e ) + throw (::com::sun::star::uno::RuntimeException) +{ + const ::osl::MutexGuard aGuard( maMutex ); + const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); + + if( mpNotifyWindow ) + { + MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), + sal::static_int_cast< USHORT >(e.ClickCount), + 0, + ( ( e.Buttons & 1 ) ? MOUSE_LEFT : 0 ) | + ( ( e.Buttons & 2 ) ? MOUSE_RIGHT : 0 ) | + ( ( e.Buttons & 4 ) ? MOUSE_MIDDLE : 0 ), + e.Modifiers ); + Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONUP, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt ); + } +} + +// --------------------------------------------------------------------- + +void SAL_CALL MediaEventListenersImpl::mouseEntered( const ::com::sun::star::awt::MouseEvent& /* e */ ) + throw (::com::sun::star::uno::RuntimeException) +{ + const ::osl::MutexGuard aGuard( maMutex ); + const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); + + if( mpNotifyWindow ) + { + } +} + +// --------------------------------------------------------------------- + +void SAL_CALL MediaEventListenersImpl::mouseExited( const ::com::sun::star::awt::MouseEvent& /* e */ ) + throw (::com::sun::star::uno::RuntimeException) +{ + const ::osl::MutexGuard aGuard( maMutex ); + const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); + + if( mpNotifyWindow ) + { + } +} + +// --------------------------------------------------------------------- + +void SAL_CALL MediaEventListenersImpl::mouseDragged( const ::com::sun::star::awt::MouseEvent& e ) + throw (::com::sun::star::uno::RuntimeException) +{ + const ::osl::MutexGuard aGuard( maMutex ); + const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); + + if( mpNotifyWindow ) + { + MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), 0, 0, e.Buttons, e.Modifiers ); + Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt ); + } +} + +// --------------------------------------------------------------------- + +void SAL_CALL MediaEventListenersImpl::mouseMoved( const ::com::sun::star::awt::MouseEvent& e ) + throw (::com::sun::star::uno::RuntimeException) +{ + const ::osl::MutexGuard aGuard( maMutex ); + const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); + + if( mpNotifyWindow ) + { + MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), 0, 0, e.Buttons, e.Modifiers ); + Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt ); + } +} + +// --------------------------------------------------------------------- + +void SAL_CALL MediaEventListenersImpl::focusGained( const ::com::sun::star::awt::FocusEvent& /* e */ ) + throw (::com::sun::star::uno::RuntimeException) +{ +} + +// --------------------------------------------------------------------- + +void SAL_CALL MediaEventListenersImpl::focusLost( const ::com::sun::star::awt::FocusEvent& /* e */ ) + throw (::com::sun::star::uno::RuntimeException) +{ +} + +} // namespace priv +} // namespace avemdia + diff --git a/avmedia/source/viewer/mediaevent_impl.hxx b/avmedia/source/viewer/mediaevent_impl.hxx new file mode 100644 index 000000000000..b06ccd885fd6 --- /dev/null +++ b/avmedia/source/viewer/mediaevent_impl.hxx @@ -0,0 +1,89 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _AVMEDIA_MEDIAEVENT_IMPL_HXX +#define _AVMEDIA_MEDIAEVENT_IMPL_HXX + +#include <avmedia/mediawindow.hxx> +#include <cppuhelper/compbase4.hxx> +#include <com/sun/star/awt/XKeyListener.hpp> +#include <com/sun/star/awt/XMouseListener.hpp> +#include <com/sun/star/awt/XMouseMotionListener.hpp> +#include <com/sun/star/awt/XFocusListener.hpp> + +namespace avmedia +{ + namespace priv + { + // --------------------------- + // - MediaEventListenersImpl - + // --------------------------- + + class MediaWindowImpl; + + class MediaEventListenersImpl : public ::cppu::WeakImplHelper4< ::com::sun::star::awt::XKeyListener, + ::com::sun::star::awt::XMouseListener, + ::com::sun::star::awt::XMouseMotionListener, + ::com::sun::star::awt::XFocusListener > + { + public: + + MediaEventListenersImpl( Window& rNotifyWindow ); + ~MediaEventListenersImpl(); + + void cleanUp(); + + protected: + + // XKeyListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL keyPressed( const ::com::sun::star::awt::KeyEvent& e ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL keyReleased( const ::com::sun::star::awt::KeyEvent& e ) throw (::com::sun::star::uno::RuntimeException); + + // XMouseListener + virtual void SAL_CALL mousePressed( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL mouseReleased( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL mouseEntered( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL mouseExited( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException); + + // XMouseMotionListener + virtual void SAL_CALL mouseDragged( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL mouseMoved( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException); + + // XFocusListener + virtual void SAL_CALL focusGained( const ::com::sun::star::awt::FocusEvent& e ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL focusLost( const ::com::sun::star::awt::FocusEvent& e ) throw (::com::sun::star::uno::RuntimeException); + + private: + + Window* mpNotifyWindow; + mutable ::osl::Mutex maMutex; + }; + } +} + +#endif diff --git a/avmedia/source/viewer/mediawindow.cxx b/avmedia/source/viewer/mediawindow.cxx new file mode 100644 index 000000000000..b2d1e5162cb5 --- /dev/null +++ b/avmedia/source/viewer/mediawindow.cxx @@ -0,0 +1,580 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <stdio.h> + +#include <avmedia/mediawindow.hxx> +#include "mediawindow_impl.hxx" +#include "mediamisc.hxx" +#include "mediawindow.hrc" +#include <tools/urlobj.hxx> +#include <vcl/msgbox.hxx> +#include <unotools/pathoptions.hxx> +#include <sfx2/filedlghelper.hxx> +#include <comphelper/processfactory.hxx> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/media/XManager.hpp> +#include "com/sun/star/ui/dialogs/TemplateDescription.hpp" + +#define AVMEDIA_FRAMEGRABBER_DEFAULTFRAME_MEDIATIME 3.0 + +using namespace ::com::sun::star; + +namespace avmedia { + +// --------------- +// - MediaWindow - +// --------------- + +MediaWindow::MediaWindow( Window* parent, bool bInternalMediaControl ) : + mpImpl( new priv::MediaWindowImpl( parent, this, bInternalMediaControl ) ) +{ + mpImpl->Show(); +} + +// ------------------------------------------------------------------------- + +MediaWindow::~MediaWindow() +{ + mpImpl->cleanUp(); + delete mpImpl; + mpImpl = NULL; +} + +// ------------------------------------------------------------------------- + +void MediaWindow::setURL( const ::rtl::OUString& rURL ) +{ + if( mpImpl ) + mpImpl->setURL( rURL ); +} + +// ------------------------------------------------------------------------- + +const ::rtl::OUString& MediaWindow::getURL() const +{ + return mpImpl->getURL(); +} + +// ------------------------------------------------------------------------- + +bool MediaWindow::isValid() const +{ + return( mpImpl != NULL && mpImpl->isValid() ); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::MouseMove( const MouseEvent& /* rMEvt */ ) +{ +} + +// --------------------------------------------------------------------- + +void MediaWindow::MouseButtonDown( const MouseEvent& /* rMEvt */ ) +{ +} + +// --------------------------------------------------------------------- + +void MediaWindow::MouseButtonUp( const MouseEvent& /* rMEvt */ ) +{ +} + +// ------------------------------------------------------------------------- + +void MediaWindow::KeyInput( const KeyEvent& /* rKEvt */ ) +{ +} + +// ------------------------------------------------------------------------- + +void MediaWindow::KeyUp( const KeyEvent& /* rKEvt */ ) +{ +} + +// ------------------------------------------------------------------------- + +void MediaWindow::Command( const CommandEvent& /* rCEvt */ ) +{ +} + +// ------------------------------------------------------------------------- + +sal_Int8 MediaWindow::AcceptDrop( const AcceptDropEvent& /* rEvt */ ) +{ + return 0; +} + +// ------------------------------------------------------------------------- + +sal_Int8 MediaWindow::ExecuteDrop( const ExecuteDropEvent& /* rEvt */ ) +{ + return 0; +} + +// ------------------------------------------------------------------------- + +void MediaWindow::StartDrag( sal_Int8 /* nAction */, const Point& /* rPosPixel */ ) +{ +} + +// ------------------------------------------------------------------------- + +bool MediaWindow::hasPreferredSize() const +{ + return( mpImpl != NULL && mpImpl->hasPreferredSize() ); +} + +// ------------------------------------------------------------------------- + +Size MediaWindow::getPreferredSize() const +{ + return mpImpl->getPreferredSize(); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::setPosSize( const Rectangle& rNewRect ) +{ + if( mpImpl ) + mpImpl->setPosSize( rNewRect ); +} + +// ------------------------------------------------------------------------- + +Rectangle MediaWindow::getPosSize() const +{ + return Rectangle( mpImpl->GetPosPixel(), mpImpl->GetSizePixel() ); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::setPointer( const Pointer& rPointer ) +{ + if( mpImpl ) + mpImpl->setPointer( rPointer ); +} + +// ------------------------------------------------------------------------- + +const Pointer& MediaWindow::getPointer() const +{ + return mpImpl->getPointer(); +} + +// ------------------------------------------------------------------------- + +bool MediaWindow::setZoom( ::com::sun::star::media::ZoomLevel eLevel ) +{ + return( mpImpl != NULL && mpImpl->setZoom( eLevel ) ); +} + +// ------------------------------------------------------------------------- + +::com::sun::star::media::ZoomLevel MediaWindow::getZoom() const +{ + return mpImpl->getZoom(); +} + +// ------------------------------------------------------------------------- + +bool MediaWindow::start() +{ + return( mpImpl != NULL && mpImpl->start() ); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::stop() +{ + if( mpImpl ) + mpImpl->stop(); +} + +// ------------------------------------------------------------------------- + +bool MediaWindow::isPlaying() const +{ + return( mpImpl != NULL && mpImpl->isPlaying() ); +} + +// ------------------------------------------------------------------------- + +double MediaWindow::getDuration() const +{ + return mpImpl->getDuration(); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::setMediaTime( double fTime ) +{ + if( mpImpl ) + mpImpl->setMediaTime( fTime ); +} + +// ------------------------------------------------------------------------- + +double MediaWindow::getMediaTime() const +{ + return mpImpl->getMediaTime(); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::setStopTime( double fTime ) +{ + if( mpImpl ) + mpImpl->setStopTime( fTime ); +} + +// ------------------------------------------------------------------------- + +double MediaWindow::getStopTime() const +{ + return mpImpl->getStopTime(); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::setRate( double fRate ) +{ + if( mpImpl ) + mpImpl->setRate( fRate ); +} + +// ------------------------------------------------------------------------- + +double MediaWindow::getRate() const +{ + return mpImpl->getRate(); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::setPlaybackLoop( bool bSet ) +{ + if( mpImpl ) + mpImpl->setPlaybackLoop( bSet ); +} + +// ------------------------------------------------------------------------- + +bool MediaWindow::isPlaybackLoop() const +{ + return mpImpl->isPlaybackLoop(); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::setMute( bool bSet ) +{ + if( mpImpl ) + mpImpl->setMute( bSet ); +} + +// ------------------------------------------------------------------------- + +bool MediaWindow::isMute() const +{ + return mpImpl->isMute(); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::updateMediaItem( MediaItem& rItem ) const +{ + if( mpImpl ) + mpImpl->updateMediaItem( rItem ); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::executeMediaItem( const MediaItem& rItem ) +{ + if( mpImpl ) + mpImpl->executeMediaItem( rItem ); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::show() +{ + if( mpImpl ) + mpImpl->Show(); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::hide() +{ + if( mpImpl ) + mpImpl->Hide(); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::enable() +{ + if( mpImpl ) + mpImpl->Enable(); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::disable() +{ + if( mpImpl ) + mpImpl->Disable(); +} + +// ------------------------------------------------------------------------- + +Window* MediaWindow::getWindow() const +{ + return mpImpl; +} + +// ------------------------------------------------------------------------- + +void MediaWindow::getMediaFilters( FilterNameVector& rFilterNameVector ) +{ + static const char* pFilters[] = { "AIF Audio", "aif;aiff", + "AU Audio", "au", + "AVI", "avi", + "CD Audio", "cda", + "MIDI Audio", "mid;midi", + "MPEG Audio", "mp2;mp3;mpa", + "MPEG Video", "mpg;mpeg;mpv;mp4", + "Ogg bitstream", "ogg", + "Quicktime Video", "mov", + "Vivo Video", "viv", + "WAVE Audio", "wav" }; + + unsigned int i; + for( i = 0; i < ( sizeof( pFilters ) / sizeof( char* ) ); i += 2 ) + { + rFilterNameVector.push_back( ::std::make_pair< ::rtl::OUString, ::rtl::OUString >( + ::rtl::OUString::createFromAscii( pFilters[ i ] ), + ::rtl::OUString::createFromAscii( pFilters[ i + 1 ] ) ) ); + } +} + +// ------------------------------------------------------------------------- + +bool MediaWindow::executeMediaURLDialog( Window* /* pParent */, ::rtl::OUString& rURL, bool bInsertDialog ) +{ + ::sfx2::FileDialogHelper aDlg( com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0 ); + static const ::rtl::OUString aWildcard( RTL_CONSTASCII_USTRINGPARAM( "*." ) ); + FilterNameVector aFilters; + const ::rtl::OUString aSeparator( RTL_CONSTASCII_USTRINGPARAM( ";" ) ); + ::rtl::OUString aAllTypes; + + aDlg.SetTitle( AVMEDIA_RESID( bInsertDialog ? AVMEDIA_STR_INSERTMEDIA_DLG : AVMEDIA_STR_OPENMEDIA_DLG ) ); + + getMediaFilters( aFilters ); + + unsigned int i; + for( i = 0; i < aFilters.size(); ++i ) + { + for( sal_Int32 nIndex = 0; nIndex >= 0; ) + { + if( aAllTypes.getLength() ) + aAllTypes += aSeparator; + + ( aAllTypes += aWildcard ) += aFilters[ i ].second.getToken( 0, ';', nIndex ); + } + } + + // add filter for all media types + aDlg.AddFilter( AVMEDIA_RESID( AVMEDIA_STR_ALL_MEDIAFILES ), aAllTypes ); + + for( i = 0; i < aFilters.size(); ++i ) + { + ::rtl::OUString aTypes; + + for( sal_Int32 nIndex = 0; nIndex >= 0; ) + { + if( aTypes.getLength() ) + aTypes += aSeparator; + + ( aTypes += aWildcard ) += aFilters[ i ].second.getToken( 0, ';', nIndex ); + } + + // add single filters + aDlg.AddFilter( aFilters[ i ].first, aTypes ); + } + + // add filter for all types + aDlg.AddFilter( AVMEDIA_RESID( AVMEDIA_STR_ALL_FILES ), String( RTL_CONSTASCII_USTRINGPARAM( "*.*" ) ) ); + + if( aDlg.Execute() == ERRCODE_NONE ) + { + const INetURLObject aURL( aDlg.GetPath() ); + rURL = aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ); + } + else if( rURL.getLength() ) + rURL = ::rtl::OUString(); + + return( rURL.getLength() > 0 ); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::executeFormatErrorBox( Window* pParent ) +{ + ErrorBox aErrBox( pParent, AVMEDIA_RESID( AVMEDIA_ERR_URL ) ); + + aErrBox.Execute(); +} + +// ------------------------------------------------------------------------- + +bool MediaWindow::isMediaURL( const ::rtl::OUString& rURL, bool bDeep, Size* pPreferredSizePixel ) +{ + const INetURLObject aURL( rURL ); + bool bRet = false; + + if( aURL.GetProtocol() != INET_PROT_NOT_VALID ) + { + if( bDeep || pPreferredSizePixel ) + { + uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); + + if( xFactory.is() ) + { + try + { + fprintf(stderr, "-->%s uno reference \n\n",AVMEDIA_MANAGER_SERVICE_NAME); + + uno::Reference< ::com::sun::star::media::XManager > xManager( + xFactory->createInstance( ::rtl::OUString::createFromAscii( AVMEDIA_MANAGER_SERVICE_NAME ) ), + uno::UNO_QUERY ); + + if( xManager.is() ) + { + uno::Reference< media::XPlayer > xPlayer( xManager->createPlayer( aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) ) ); + + if( xPlayer.is() ) + { + bRet = true; + + if( pPreferredSizePixel ) + { + const awt::Size aAwtSize( xPlayer->getPreferredPlayerWindowSize() ); + + pPreferredSizePixel->Width() = aAwtSize.Width; + pPreferredSizePixel->Height() = aAwtSize.Height; + } + } + } + } + catch( ... ) + { + } + } + } + else + { + FilterNameVector aFilters; + const ::rtl::OUString aExt( aURL.getExtension() ); + + getMediaFilters( aFilters ); + + unsigned int i; + for( i = 0; ( i < aFilters.size() ) && !bRet; ++i ) + { + for( sal_Int32 nIndex = 0; nIndex >= 0 && !bRet; ) + { + if( aExt.equalsIgnoreAsciiCase( aFilters[ i ].second.getToken( 0, ';', nIndex ) ) ) + bRet = true; + } + } + } + } + + return bRet; +} + +// ------------------------------------------------------------------------- + +uno::Reference< media::XPlayer > MediaWindow::createPlayer( const ::rtl::OUString& rURL ) +{ + return priv::MediaWindowImpl::createPlayer( rURL ); +} + +// ------------------------------------------------------------------------- + +uno::Reference< graphic::XGraphic > MediaWindow::grabFrame( const ::rtl::OUString& rURL, + bool bAllowToCreateReplacementGraphic, + double fMediaTime ) +{ + uno::Reference< media::XPlayer > xPlayer( createPlayer( rURL ) ); + uno::Reference< graphic::XGraphic > xRet; + ::std::auto_ptr< Graphic > apGraphic; + + if( xPlayer.is() ) + { + uno::Reference< media::XFrameGrabber > xGrabber( xPlayer->createFrameGrabber() ); + + if( xGrabber.is() ) + { + if( AVMEDIA_FRAMEGRABBER_DEFAULTFRAME == fMediaTime ) + fMediaTime = AVMEDIA_FRAMEGRABBER_DEFAULTFRAME_MEDIATIME; + + if( fMediaTime >= xPlayer->getDuration() ) + fMediaTime = ( xPlayer->getDuration() * 0.5 ); + + xRet = xGrabber->grabFrame( fMediaTime ); + } + + if( !xRet.is() && bAllowToCreateReplacementGraphic ) + { + awt::Size aPrefSize( xPlayer->getPreferredPlayerWindowSize() ); + + if( !aPrefSize.Width && !aPrefSize.Height ) + { + const BitmapEx aBmpEx( AVMEDIA_RESID( AVMEDIA_BMP_AUDIOLOGO ) ); + apGraphic.reset( new Graphic( aBmpEx ) ); + } + } + } + + if( !xRet.is() && !apGraphic.get() && bAllowToCreateReplacementGraphic ) + { + const BitmapEx aBmpEx( AVMEDIA_RESID( AVMEDIA_BMP_EMPTYLOGO ) ); + apGraphic.reset( new Graphic( aBmpEx ) ); + } + + if( apGraphic.get() ) + xRet = apGraphic->GetXGraphic(); + + return xRet; +} + +} // namespace avemdia diff --git a/avmedia/source/viewer/mediawindow.hrc b/avmedia/source/viewer/mediawindow.hrc new file mode 100644 index 000000000000..67036e300c13 --- /dev/null +++ b/avmedia/source/viewer/mediawindow.hrc @@ -0,0 +1,9 @@ +#define AVMEDIA_STR_OPENMEDIA_DLG 16384 +#define AVMEDIA_STR_INSERTMEDIA_DLG 16385 +#define AVMEDIA_STR_ALL_MEDIAFILES 16386 +#define AVMEDIA_STR_ALL_FILES 16387 + +#define AVMEDIA_BMP_AUDIOLOGO 20000 +#define AVMEDIA_BMP_EMPTYLOGO 20001 + +#define AVMEDIA_ERR_URL 21000 diff --git a/avmedia/source/viewer/mediawindow.src b/avmedia/source/viewer/mediawindow.src new file mode 100644 index 000000000000..1c92b4d913af --- /dev/null +++ b/avmedia/source/viewer/mediawindow.src @@ -0,0 +1,77 @@ + /************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "mediawindow.hrc" + +String AVMEDIA_STR_INSERTMEDIA_DLG +{ + Text[en-US] = "Insert Movie and Sound"; +}; + +// ------------------------------------------------------------------------------ + +STRING AVMEDIA_STR_OPENMEDIA_DLG +{ + Text[en-US] = "Open Movie and Sound"; +}; + +// ------------------------------------------------------------------------------ + +String AVMEDIA_STR_ALL_MEDIAFILES +{ + Text[en-US] = "All movie and sound files"; +}; + +// ------------------------------------------------------------------------------ + +String AVMEDIA_STR_ALL_FILES +{ + Text[en-US] = "All files (*.*)"; +}; + +// ------------------------------------------------------------------------------ + +Bitmap AVMEDIA_BMP_AUDIOLOGO +{ + file = "avaudiologo.png"; +}; + +// ------------------------------------------------------------------------------ + +Bitmap AVMEDIA_BMP_EMPTYLOGO +{ + file = "avemptylogo.png"; +}; + +// ------------------------------------------------------------------------------ + +ErrorBox AVMEDIA_ERR_URL +{ + BUTTONS = WB_OK ; + DEFBUTTON = WB_DEF_OK ; + Message[en-US] = "The format of the selected file is not supported."; +}; diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx new file mode 100644 index 000000000000..553eea6196c1 --- /dev/null +++ b/avmedia/source/viewer/mediawindow_impl.cxx @@ -0,0 +1,546 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "mediawindow_impl.hxx" +#include "mediaevent_impl.hxx" +#include "mediamisc.hxx" +#include "mediawindow.hrc" +#include "helpids.hrc" + +#include <algorithm> +#include <cmath> +#include <osl/mutex.hxx> +#include <tools/time.hxx> +#include <vcl/svapp.hxx> + +#ifndef _COM_SUN_STAR_AWT_SYSTEMPOINTER_HDL_ +#include <com/sun/star/awt/SystemPointer.hdl> +#endif +#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HDL_ +#include <com/sun/star/lang/XComponent.hdl> +#endif + +#define AVMEDIA_TOOLBOXITEM_PREV 0x0001 +#define AVMEDIA_TOOLBOXITEM_PLAY 0x0002 +#define AVMEDIA_TOOLBOXITEM_PAUSE 0x0004 +#define AVMEDIA_TOOLBOXITEM_STOP 0x0008 +#define AVMEDIA_TOOLBOXITEM_NEXT 0x0010 +#define AVMEDIA_TOOLBOXITEM_MUTE 0x0100 + +#define AVMEDIA_FFW_PLAYRATE 4 + +using namespace ::com::sun::star; + +namespace avmedia { namespace priv { + +// ---------------------- +// - MediaWindowControl - +// ---------------------- + +MediaWindowControl::MediaWindowControl( Window* pParent ) : + MediaControl( pParent, MEDIACONTROLSTYLE_MULTILINE ) +{ +} + +// --------------------------------------------------------------------- + +MediaWindowControl::~MediaWindowControl() +{ +} + +// --------------------------------------------------------------------- + +void MediaWindowControl::update() +{ + MediaItem aItem; + + static_cast< MediaWindowImpl* >( GetParent() )->updateMediaItem( aItem ); + setState( aItem ); +} + +// --------------------------------------------------------------------- + +void MediaWindowControl::execute( const MediaItem& rItem ) +{ + static_cast< MediaWindowImpl* >( GetParent() )->executeMediaItem( rItem ); +} + +// -------------------- +// - MediaChildWindow - +// -------------------- + +MediaChildWindow::MediaChildWindow( Window* pParent ) : + JavaChildWindow( pParent, WB_CLIPCHILDREN ) +{ +} + +// --------------------------------------------------------------------- + +MediaChildWindow::~MediaChildWindow() +{ +} + +// --------------------------------------------------------------------- + +void MediaChildWindow::MouseMove( const MouseEvent& rMEvt ) +{ + const MouseEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ), + rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() ); + + JavaChildWindow::MouseMove( rMEvt ); + GetParent()->MouseMove( aTransformedEvent ); +} + +// --------------------------------------------------------------------- + +void MediaChildWindow::MouseButtonDown( const MouseEvent& rMEvt ) +{ + const MouseEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ), + rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() ); + + JavaChildWindow::MouseButtonDown( rMEvt ); + GetParent()->MouseButtonDown( aTransformedEvent ); +} + +// --------------------------------------------------------------------- + +void MediaChildWindow::MouseButtonUp( const MouseEvent& rMEvt ) +{ + const MouseEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ), + rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() ); + + JavaChildWindow::MouseButtonUp( rMEvt ); + GetParent()->MouseButtonUp( aTransformedEvent ); +} + +// --------------------------------------------------------------------- + +void MediaChildWindow::KeyInput( const KeyEvent& rKEvt ) +{ + JavaChildWindow::KeyInput( rKEvt ); + GetParent()->KeyInput( rKEvt ); +} + +// --------------------------------------------------------------------- + +void MediaChildWindow::KeyUp( const KeyEvent& rKEvt ) +{ + JavaChildWindow::KeyUp( rKEvt ); + GetParent()->KeyUp( rKEvt ); +} + +// --------------------------------------------------------------------- + +void MediaChildWindow::Command( const CommandEvent& rCEvt ) +{ + const CommandEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rCEvt.GetMousePosPixel() ) ), + rCEvt.GetCommand(), rCEvt.IsMouseEvent(), rCEvt.GetData() ); + + JavaChildWindow::Command( rCEvt ); + GetParent()->Command( aTransformedEvent ); +} + +// ---------------------- +// - MediaWindowImpl - +// ---------------------- + +MediaWindowImpl::MediaWindowImpl( Window* pParent, MediaWindow* pMediaWindow, bool bInternalMediaControl ) : + Control( pParent ), + MediaWindowBaseImpl( pMediaWindow ), + DropTargetHelper( this ), + DragSourceHelper( this ), + mxEventsIf( static_cast< ::cppu::OWeakObject* >( mpEvents = new MediaEventListenersImpl( maChildWindow ) ) ), + maChildWindow( this ), + mpMediaWindowControl( bInternalMediaControl ? new MediaWindowControl( this ) : NULL ), + mpEmptyBmpEx( NULL ), + mpAudioBmpEx( NULL ) +{ + maChildWindow.SetHelpId( HID_AVMEDIA_PLAYERWINDOW ); + maChildWindow.Hide(); + + if( mpMediaWindowControl ) + { + mpMediaWindowControl->SetSizePixel( mpMediaWindowControl->getMinSizePixel() ); + mpMediaWindowControl->Show(); + } +} + +// --------------------------------------------------------------------- + +MediaWindowImpl::~MediaWindowImpl() +{ + delete mpEmptyBmpEx; + delete mpAudioBmpEx; + delete mpMediaWindowControl; +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::cleanUp() +{ + uno::Reference< media::XPlayerWindow > xPlayerWindow( getPlayerWindow() ); + + mpEvents->cleanUp(); + + if( xPlayerWindow.is() ) + { + xPlayerWindow->removeKeyListener( uno::Reference< awt::XKeyListener >( mxEventsIf, uno::UNO_QUERY ) ); + xPlayerWindow->removeMouseListener( uno::Reference< awt::XMouseListener >( mxEventsIf, uno::UNO_QUERY ) ); + xPlayerWindow->removeMouseMotionListener( uno::Reference< awt::XMouseMotionListener >( mxEventsIf, uno::UNO_QUERY ) ); + + uno::Reference< lang::XComponent > xComponent( xPlayerWindow, uno::UNO_QUERY ); + + if( xComponent.is() ) + xComponent->dispose(); + + setPlayerWindow( NULL ); + } + + MediaWindowBaseImpl::cleanUp(); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::onURLChanged() +{ + if( getPlayer().is() ) + { + uno::Sequence< uno::Any > aArgs( 2 ); + uno::Reference< media::XPlayerWindow > xPlayerWindow; + const Point aPoint; + const Size aSize( maChildWindow.GetSizePixel() ); + const sal_IntPtr nWndHandle = static_cast< sal_IntPtr >( maChildWindow.getParentWindowHandleForJava() ); + + aArgs[ 0 ] = uno::makeAny( nWndHandle ); + aArgs[ 1 ] = uno::makeAny( awt::Rectangle( aPoint.X(), aPoint.Y(), aSize.Width(), aSize.Height() ) ); + + try + { + if( nWndHandle != 0 ) + xPlayerWindow = getPlayer()->createPlayerWindow( aArgs ); + } + catch( uno::RuntimeException ) + { + // happens eg, on MacOSX where Java frames cannot be created from X11 window handles + } + + setPlayerWindow( xPlayerWindow ); + + if( xPlayerWindow.is() ) + { + xPlayerWindow->addKeyListener( uno::Reference< awt::XKeyListener >( mxEventsIf, uno::UNO_QUERY ) ); + xPlayerWindow->addMouseListener( uno::Reference< awt::XMouseListener >( mxEventsIf, uno::UNO_QUERY ) ); + xPlayerWindow->addMouseMotionListener( uno::Reference< awt::XMouseMotionListener >( mxEventsIf, uno::UNO_QUERY ) ); + xPlayerWindow->addFocusListener( uno::Reference< awt::XFocusListener >( mxEventsIf, uno::UNO_QUERY ) ); + } + } + else + setPlayerWindow( NULL ); + + if( getPlayerWindow().is() ) + maChildWindow.Show(); + else + maChildWindow.Hide(); + + if( mpMediaWindowControl ) + { + MediaItem aItem; + + updateMediaItem( aItem ); + mpMediaWindowControl->setState( aItem ); + } + + Invalidate(); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::update() +{ + uno::Reference< media::XPlayerWindow > xPlayerWindow( getPlayerWindow() ); + + if( xPlayerWindow.is() ) + xPlayerWindow->update(); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::setPosSize( const Rectangle& rRect ) +{ + SetPosSizePixel( rRect.Left(), rRect.Top(), rRect.GetWidth(), rRect.GetHeight() ); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::setPointer( const Pointer& rPointer ) +{ + uno::Reference< media::XPlayerWindow > xPlayerWindow( getPlayerWindow() ); + + SetPointer( rPointer ); + maChildWindow.SetPointer( rPointer ); + + if( xPlayerWindow.is() ) + { + + long nPointer; + + switch( rPointer.GetStyle() ) + { + case( POINTER_CROSS ): nPointer = awt::SystemPointer::CROSS; break; + case( POINTER_HAND ): nPointer = awt::SystemPointer::HAND; break; + case( POINTER_MOVE ): nPointer = awt::SystemPointer::MOVE; break; + case( POINTER_WAIT ): nPointer = awt::SystemPointer::WAIT; break; + + default: nPointer = awt::SystemPointer::ARROW; break; + } + + xPlayerWindow->setPointerType( nPointer ); + } +} + +// --------------------------------------------------------------------- + +const Pointer& MediaWindowImpl::getPointer() const +{ + return GetPointer(); +} + +// --------------------------------------------------------------------- + +bool MediaWindowImpl::hasInternalMediaControl() const +{ + return( mpMediaWindowControl != NULL ); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::Resize() +{ + uno::Reference< media::XPlayerWindow > xPlayerWindow( getPlayerWindow() ); + const Size aCurSize( GetOutputSizePixel() ); + const sal_Int32 nOffset( mpMediaWindowControl ? AVMEDIA_CONTROLOFFSET : 0 ); + Size aPlayerWindowSize( aCurSize.Width() - ( nOffset << 1 ), + aCurSize.Height() - ( nOffset << 1 ) ); + + if( mpMediaWindowControl ) + { + const sal_Int32 nControlHeight = mpMediaWindowControl->GetSizePixel().Height(); + const sal_Int32 nControlY = ::std::max( aCurSize.Height() - nControlHeight - nOffset, 0L ); + + aPlayerWindowSize.Height() = ( nControlY - ( nOffset << 1 ) ); + mpMediaWindowControl->SetPosSizePixel( Point( nOffset, nControlY ), Size( aCurSize.Width() - ( nOffset << 1 ), nControlHeight ) ); + } + + maChildWindow.SetPosSizePixel( Point( nOffset, nOffset ), aPlayerWindowSize ); + + if( xPlayerWindow.is() ) + xPlayerWindow->setPosSize( 0, 0, aPlayerWindowSize.Width(), aPlayerWindowSize.Height(), 0 ); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::StateChanged( StateChangedType eType ) +{ + uno::Reference< media::XPlayerWindow > xPlayerWindow( getPlayerWindow() ); + + if( xPlayerWindow.is() ) + { + // stop playing when going disabled or hidden + switch( eType ) + { + case STATE_CHANGE_VISIBLE: + { + stopPlayingInternal( !IsVisible() ); + xPlayerWindow->setVisible( IsVisible() ); + } + break; + + case STATE_CHANGE_ENABLE: + { + stopPlayingInternal( !IsEnabled() ); + xPlayerWindow->setEnable( IsEnabled() ); + } + break; + + default: + break; + } + } +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::Paint( const Rectangle& ) +{ + BitmapEx* pLogo = NULL; + + if( !getPlayer().is() ) + { + if( !mpEmptyBmpEx ) + mpEmptyBmpEx = new BitmapEx( AVMEDIA_RESID( AVMEDIA_BMP_EMPTYLOGO ) ); + + pLogo = mpEmptyBmpEx; + } + else if ( !getPlayerWindow().is() ) + { + if( !mpAudioBmpEx ) + mpAudioBmpEx = new BitmapEx( AVMEDIA_RESID( AVMEDIA_BMP_AUDIOLOGO ) ); + + pLogo = mpAudioBmpEx; + } + + const Point aBasePos( maChildWindow.GetPosPixel() ); + const Rectangle aVideoRect( aBasePos, maChildWindow.GetSizePixel() ); + + if( pLogo && !pLogo->IsEmpty() && ( aVideoRect.GetWidth() > 0 ) && ( aVideoRect.GetHeight() > 0 ) ) + { + Size aLogoSize( pLogo->GetSizePixel() ); + const Color aBackgroundColor( 67, 67, 67 ); + + SetLineColor( aBackgroundColor ); + SetFillColor( aBackgroundColor ); + DrawRect( aVideoRect ); + + if( ( aLogoSize.Width() > aVideoRect.GetWidth() || aLogoSize.Height() > aVideoRect.GetHeight() ) && + ( aLogoSize.Height() > 0 ) ) + { + const double fLogoWH = (double) aLogoSize.Width() / aLogoSize.Height(); + + if( fLogoWH < ( (double) aVideoRect.GetWidth() / aVideoRect.GetHeight() ) ) + { + aLogoSize.Width() = (long) ( aVideoRect.GetHeight() * fLogoWH ); + aLogoSize.Height()= aVideoRect.GetHeight(); + } + else + { + aLogoSize.Width() = aVideoRect.GetWidth(); + aLogoSize.Height()= (long) ( aVideoRect.GetWidth() / fLogoWH ); + } + } + + DrawBitmapEx( Point( aBasePos.X() + ( ( aVideoRect.GetWidth() - aLogoSize.Width() ) >> 1 ), + aBasePos.Y() + ( ( aVideoRect.GetHeight() - aLogoSize.Height() ) >> 1 ) ), + aLogoSize, *pLogo ); + } + + update(); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::GetFocus() +{ +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::MouseMove( const MouseEvent& rMEvt ) +{ + MediaWindow* pMediaWindow = getMediaWindow(); + + if( pMediaWindow ) + pMediaWindow->MouseMove( rMEvt ); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::MouseButtonDown( const MouseEvent& rMEvt ) +{ + MediaWindow* pMediaWindow = getMediaWindow(); + + if( pMediaWindow ) + pMediaWindow->MouseButtonDown( rMEvt ); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::MouseButtonUp( const MouseEvent& rMEvt ) +{ + MediaWindow* pMediaWindow = getMediaWindow(); + + if( pMediaWindow ) + pMediaWindow->MouseButtonUp( rMEvt ); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::KeyInput( const KeyEvent& rKEvt ) +{ + MediaWindow* pMediaWindow = getMediaWindow(); + + if( pMediaWindow ) + pMediaWindow->KeyInput( rKEvt ); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::KeyUp( const KeyEvent& rKEvt ) +{ + MediaWindow* pMediaWindow = getMediaWindow(); + + if( pMediaWindow ) + pMediaWindow->KeyUp( rKEvt ); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::Command( const CommandEvent& rCEvt ) +{ + MediaWindow* pMediaWindow = getMediaWindow(); + + if( pMediaWindow ) + pMediaWindow->Command( rCEvt ); +} + +// --------------------------------------------------------------------- + +sal_Int8 MediaWindowImpl::AcceptDrop( const AcceptDropEvent& rEvt ) +{ + MediaWindow* pMediaWindow = getMediaWindow(); + return( pMediaWindow ? pMediaWindow->AcceptDrop( rEvt ) : 0 ); +} + +// --------------------------------------------------------------------- + +sal_Int8 MediaWindowImpl::ExecuteDrop( const ExecuteDropEvent& rEvt ) +{ + MediaWindow* pMediaWindow = getMediaWindow(); + return( pMediaWindow ? pMediaWindow->ExecuteDrop( rEvt ) : 0 ); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::StartDrag( sal_Int8 nAction, const Point& rPosPixel ) +{ + MediaWindow* pMediaWindow = getMediaWindow(); + + if( pMediaWindow ) + pMediaWindow->StartDrag( nAction, rPosPixel ); +} + +} // namespace priv +} // namespace avmedia diff --git a/avmedia/source/viewer/mediawindow_impl.hxx b/avmedia/source/viewer/mediawindow_impl.hxx new file mode 100644 index 000000000000..679b864af6b7 --- /dev/null +++ b/avmedia/source/viewer/mediawindow_impl.hxx @@ -0,0 +1,145 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _AVMEDIA_MEDIAWINDOW_IMPL_HXX +#define _AVMEDIA_MEDIAWINDOW_IMPL_HXX + +#include <svtools/transfer.hxx> +#include <vcl/javachild.hxx> + +#include "mediawindowbase_impl.hxx" +#include "mediacontrol.hxx" + +class BitmapEx; + +namespace avmedia +{ + namespace priv + { + // ---------------------- + // - MediaWindowControl - + // ---------------------- + + class MediaWindowControl : public MediaControl + { + public: + + MediaWindowControl( Window* pParent ); + ~MediaWindowControl(); + + protected: + + void update(); + void execute( const MediaItem& rItem ); + }; + + // -------------------- + // - MediaChildWindow - + // -------------------- + + class MediaChildWindow : public JavaChildWindow + { + public: + + MediaChildWindow( Window* pParent ); + ~MediaChildWindow(); + + protected: + + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void KeyUp( const KeyEvent& rKEvt ); + virtual void Command( const CommandEvent& rCEvt ); + }; + + // ------------------. + // - MediaWindowImpl - + // ------------------- + + class MediaEventListenersImpl; + + class MediaWindowImpl : public Control, + public MediaWindowBaseImpl, + public DropTargetHelper, + public DragSourceHelper + + { + public: + + MediaWindowImpl( Window* parent, MediaWindow* pMediaWindow, bool bInternalMediaControl ); + virtual ~MediaWindowImpl(); + + virtual void cleanUp(); + virtual void onURLChanged(); + + public: + + void update(); + + void setPosSize( const Rectangle& rRect ); + + void setPointer( const Pointer& rPointer ); + const Pointer& getPointer() const; + + bool hasInternalMediaControl() const; + + protected: + + // Window + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void KeyUp( const KeyEvent& rKEvt ); + virtual void Command( const CommandEvent& rCEvt ); + virtual void Resize(); + virtual void StateChanged( StateChangedType ); + virtual void Paint( const Rectangle& ); // const + virtual void GetFocus(); + + // DropTargetHelper + virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ); + virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ); + + // DragSourceHelper + virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ); + + private: + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxEventsIf; + MediaEventListenersImpl* mpEvents; + MediaChildWindow maChildWindow; + MediaWindowControl* mpMediaWindowControl; + BitmapEx* mpEmptyBmpEx; + BitmapEx* mpAudioBmpEx; + }; + } +} + +#endif diff --git a/avmedia/source/viewer/mediawindowbase_impl.cxx b/avmedia/source/viewer/mediawindowbase_impl.cxx new file mode 100644 index 000000000000..ea28121e3609 --- /dev/null +++ b/avmedia/source/viewer/mediawindowbase_impl.cxx @@ -0,0 +1,442 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "mediawindowbase_impl.hxx" +#include <avmedia/mediaitem.hxx> +#include "mediamisc.hxx" +#include "mediawindow.hrc" +#include <tools/urlobj.hxx> +#include <comphelper/processfactory.hxx> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/media/XManager.hpp> +#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HDL_ +#include <com/sun/star/lang/XComponent.hdl> +#endif + +#define MEDIA_TIMER_TIMEOUT 100 + +using namespace ::com::sun::star; + +namespace avmedia { namespace priv { + +// ----------------------- +// - MediaWindowBaseImpl - +// ----------------------- + +MediaWindowBaseImpl::MediaWindowBaseImpl( MediaWindow* pMediaWindow ) : + mpMediaWindow( pMediaWindow ) +{ +} + +// --------------------------------------------------------------------- + +MediaWindowBaseImpl::~MediaWindowBaseImpl() +{ + uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); +} + +// ------------------------------------------------------------------------- + +uno::Reference< media::XPlayer > MediaWindowBaseImpl::createPlayer( const ::rtl::OUString& rURL ) +{ + uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); + uno::Reference< media::XPlayer > xPlayer; + + if( xFactory.is() ) + { + try + { + + uno::Reference< ::com::sun::star::media::XManager > xManager( + xFactory->createInstance( ::rtl::OUString::createFromAscii( AVMEDIA_MANAGER_SERVICE_NAME ) ), + uno::UNO_QUERY ); + + if( xManager.is() ) + { + xPlayer = uno::Reference< ::com::sun::star::media::XPlayer >( + xManager->createPlayer( rURL ), uno::UNO_QUERY ); + } + } + catch( ... ) + { + } + } + + return xPlayer; +} + + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::setURL( const ::rtl::OUString& rURL ) +{ + if( rURL != getURL() ) + { + INetURLObject aURL( maFileURL = rURL ); + + if( mxPlayer.is() ) + mxPlayer->stop(); + + if( mxPlayerWindow.is() ) + { + mxPlayerWindow->setVisible( false ); + mxPlayerWindow.clear(); + } + + mxPlayer.clear(); + + if( aURL.GetProtocol() != INET_PROT_NOT_VALID ) + maFileURL = aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ); + + mxPlayer = createPlayer( maFileURL ); + onURLChanged(); + } +} + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::onURLChanged() +{ +} + +// --------------------------------------------------------------------- + +const ::rtl::OUString& MediaWindowBaseImpl::getURL() const +{ + return maFileURL; +} + +// --------------------------------------------------------------------- + +bool MediaWindowBaseImpl::isValid() const +{ + return( getPlayer().is() ); +} + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::stopPlayingInternal( bool bStop ) +{ + if( isPlaying() ) + { + if( bStop ) + mxPlayer->stop(); + else + mxPlayer->start(); + } +} + +// --------------------------------------------------------------------- + +MediaWindow* MediaWindowBaseImpl::getMediaWindow() const +{ + return mpMediaWindow; +} + +// --------------------------------------------------------------------- + +uno::Reference< media::XPlayer > MediaWindowBaseImpl::getPlayer() const +{ + return mxPlayer; +} + +// --------------------------------------------------------------------- + +uno::Reference< media::XPlayerWindow > MediaWindowBaseImpl::getPlayerWindow() const +{ + return mxPlayerWindow; +} + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::setPlayerWindow( const uno::Reference< media::XPlayerWindow >& rxPlayerWindow ) +{ + mxPlayerWindow = rxPlayerWindow; +} + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::cleanUp() +{ + if( mxPlayer.is() ) + { + mxPlayer->stop(); + + uno::Reference< lang::XComponent > xComponent( mxPlayer, uno::UNO_QUERY ); + + if( xComponent.is() ) + xComponent->dispose(); + + mxPlayer.clear(); + } + + mpMediaWindow = NULL; +} + +// --------------------------------------------------------------------- + +bool MediaWindowBaseImpl::hasPreferredSize() const +{ + return( mxPlayerWindow.is() ); +} + +// --------------------------------------------------------------------- + +Size MediaWindowBaseImpl::getPreferredSize() const +{ + Size aRet; + + if( mxPlayer.is() ) + { + awt::Size aPrefSize( mxPlayer->getPreferredPlayerWindowSize() ); + + aRet.Width() = aPrefSize.Width; + aRet.Height() = aPrefSize.Height; + } + + return aRet; +} + +// --------------------------------------------------------------------- + +bool MediaWindowBaseImpl::setZoom( ::com::sun::star::media::ZoomLevel eLevel ) +{ + return( mxPlayerWindow.is() ? mxPlayerWindow->setZoomLevel( eLevel ) : false ); +} + +// ------------------------------------------------------------------------- + +::com::sun::star::media::ZoomLevel MediaWindowBaseImpl::getZoom() const +{ + return( mxPlayerWindow.is() ? mxPlayerWindow->getZoomLevel() : ::com::sun::star::media::ZoomLevel_NOT_AVAILABLE ); +} + +// --------------------------------------------------------------------- + +bool MediaWindowBaseImpl::start() +{ + return( mxPlayer.is() ? ( mxPlayer->start(), true ) : false ); +} + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::stop() +{ + if( mxPlayer.is() ) + mxPlayer->stop(); +} + +// --------------------------------------------------------------------- + +bool MediaWindowBaseImpl::isPlaying() const +{ + return( mxPlayer.is() && mxPlayer->isPlaying() ); +} + +// --------------------------------------------------------------------- + +double MediaWindowBaseImpl::getDuration() const +{ + return( mxPlayer.is() ? mxPlayer->getDuration() : 0.0 ); +} + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::setMediaTime( double fTime ) +{ + if( mxPlayer.is() ) + mxPlayer->setMediaTime( fTime ); +} + +// --------------------------------------------------------------------- + +double MediaWindowBaseImpl::getMediaTime() const +{ + return( mxPlayer.is() ? mxPlayer->getMediaTime() : 0.0 ); +} + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::setStopTime( double fTime ) +{ + if( mxPlayer.is() ) + mxPlayer->setStopTime( fTime ); +} + +// --------------------------------------------------------------------- + +double MediaWindowBaseImpl::getStopTime() const +{ + return( mxPlayer.is() ? mxPlayer->getStopTime() : 0.0 ); +} + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::setRate( double fRate ) +{ + if( mxPlayer.is() ) + mxPlayer->setRate( fRate ); +} + +// --------------------------------------------------------------------- + +double MediaWindowBaseImpl::getRate() const +{ + return( mxPlayer.is() ? mxPlayer->getRate() : 0.0 ); +} + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::setPlaybackLoop( bool bSet ) +{ + if( mxPlayer.is() ) + mxPlayer->setPlaybackLoop( bSet ); +} + +// --------------------------------------------------------------------- + +bool MediaWindowBaseImpl::isPlaybackLoop() const +{ + return( mxPlayer.is() ? mxPlayer->isPlaybackLoop() : false ); +} + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::setMute( bool bSet ) +{ + if( mxPlayer.is() ) + mxPlayer->setMute( bSet ); +} + +// --------------------------------------------------------------------- + +bool MediaWindowBaseImpl::isMute() const +{ + return( mxPlayer.is() ? mxPlayer->isMute() : false ); +} + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::setVolumeDB( sal_Int16 nVolumeDB ) +{ + if( mxPlayer.is() ) + mxPlayer->setVolumeDB( nVolumeDB ); +} + +// --------------------------------------------------------------------- + +sal_Int16 MediaWindowBaseImpl::getVolumeDB() const +{ + return( mxPlayer.is() ? mxPlayer->getVolumeDB() : 0 ); +} + +// ------------------------------------------------------------------------- + +void MediaWindowBaseImpl::updateMediaItem( MediaItem& rItem ) const +{ + if( isPlaying() ) + rItem.setState( ( getRate() > 1.0 ) ? MEDIASTATE_PLAYFFW : MEDIASTATE_PLAY ); + else + rItem.setState( ( 0.0 == getMediaTime() ) ? MEDIASTATE_STOP : MEDIASTATE_PAUSE ); + + rItem.setDuration( getDuration() ); + rItem.setTime( getMediaTime() ); + rItem.setLoop( isPlaybackLoop() ); + rItem.setMute( isMute() ); + rItem.setVolumeDB( getVolumeDB() ); + rItem.setZoom( getZoom() ); + rItem.setURL( getURL() ); +} + +// ------------------------------------------------------------------------- + +void MediaWindowBaseImpl::executeMediaItem( const MediaItem& rItem ) +{ + const sal_uInt32 nMaskSet = rItem.getMaskSet(); + + // set URL first + if( nMaskSet & AVMEDIA_SETMASK_URL ) + setURL( rItem.getURL() ); + + // set different states next + if( nMaskSet & AVMEDIA_SETMASK_TIME ) + setMediaTime( ::std::min( rItem.getTime(), getDuration() ) ); + + if( nMaskSet & AVMEDIA_SETMASK_LOOP ) + setPlaybackLoop( rItem.isLoop() ); + + if( nMaskSet & AVMEDIA_SETMASK_MUTE ) + setMute( rItem.isMute() ); + + if( nMaskSet & AVMEDIA_SETMASK_VOLUMEDB ) + setVolumeDB( rItem.getVolumeDB() ); + + if( nMaskSet & AVMEDIA_SETMASK_ZOOM ) + setZoom( rItem.getZoom() ); + + // set play state at last + if( nMaskSet & AVMEDIA_SETMASK_STATE ) + { + switch( rItem.getState() ) + { + case( MEDIASTATE_PLAY ): + case( MEDIASTATE_PLAYFFW ): + { +/* + const double fNewRate = ( ( MEDIASTATE_PLAYFFW == rItem.getState() ) ? AVMEDIA_FFW_PLAYRATE : 1.0 ); + + if( getRate() != fNewRate ) + setRate( fNewRate ); +*/ + if( !isPlaying() ) + start(); + } + break; + + case( MEDIASTATE_PAUSE ): + { + if( isPlaying() ) + stop(); + } + break; + + case( MEDIASTATE_STOP ): + { + if( isPlaying() ) + { + setMediaTime( 0.0 ); + stop(); + setMediaTime( 0.0 ); + } + } + break; + } + } +} + +} // namespace priv +} // namespace avemdia diff --git a/avmedia/source/viewer/mediawindowbase_impl.hxx b/avmedia/source/viewer/mediawindowbase_impl.hxx new file mode 100644 index 000000000000..0b0f160b6e3c --- /dev/null +++ b/avmedia/source/viewer/mediawindowbase_impl.hxx @@ -0,0 +1,131 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _AVMEDIA_MEDIAWINDOWBASE_IMPL_HXX +#define _AVMEDIA_MEDIAWINDOWBASE_IMPL_HXX + +#include <avmedia/mediawindow.hxx> +#include <com/sun/star/media/XPlayer.hpp> +#include <com/sun/star/media/XPlayerWindow.hpp> + +namespace avmedia +{ + namespace priv + { + // -------------- + // - UpdateMode - + // -------------- + + enum UpdateMode + { + UPDATEMODE_SYNC_STATUSBAR = 0, + UPDATEMODE_SYNC_PLAYER = 1, + UPDATEMODE_SYNC_NONE = 2 + }; + + // ----------------------- + // - MediaWindowBaseImpl - + // ----------------------- + + class MediaWindowBaseImpl + { + public: + + MediaWindowBaseImpl( MediaWindow* pMediaWindow ); + virtual ~MediaWindowBaseImpl(); + + virtual void cleanUp(); + virtual void onURLChanged(); + + static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const ::rtl::OUString& rURL ); + + public: + + void setURL( const ::rtl::OUString& rURL ); + const ::rtl::OUString& getURL() const; + + bool isValid() const; + + bool hasPreferredSize() const; + Size getPreferredSize() const; + + bool setZoom( ::com::sun::star::media::ZoomLevel eLevel ); + ::com::sun::star::media::ZoomLevel getZoom() const; + + bool start(); + void stop(); + + bool isPlaying() const; + + double getDuration() const; + + void setMediaTime( double fTime ); + double getMediaTime() const; + + void setStopTime( double fTime ); + double getStopTime() const; + + void setRate( double fRate ); + double getRate() const; + + void setPlaybackLoop( bool bSet ); + bool isPlaybackLoop() const; + + void setFixedAspectRatio( bool bSet ); + bool isFixedAspectRatio() const; + + void setMute( bool bSet ); + bool isMute() const; + + void setVolumeDB( sal_Int16 nVolumeDB ); + sal_Int16 getVolumeDB() const; + + void updateMediaItem( MediaItem& rItem ) const; + void executeMediaItem( const MediaItem& rItem ); + + protected: + + void stopPlayingInternal( bool ); + + MediaWindow* getMediaWindow() const; + + ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > getPlayer() const; + + void setPlayerWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow >& rxPlayerWindow ); + ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > getPlayerWindow() const; + + private: + + ::rtl::OUString maFileURL; + ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > mxPlayer; + ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > mxPlayerWindow; + MediaWindow* mpMediaWindow; + }; + } +} + +#endif |