2004-08-23 08:04:42 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-07 18:43:09 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-08-23 08:04:42 +00:00
|
|
|
*
|
2005-09-07 18:43:09 +00:00
|
|
|
* $RCSfile: mediawindow.cxx,v $
|
2004-08-23 08:04:42 +00:00
|
|
|
*
|
2007-06-27 21:24:05 +00:00
|
|
|
* $Revision: 1.7 $
|
2004-08-23 08:04:42 +00:00
|
|
|
*
|
2007-06-27 21:24:05 +00:00
|
|
|
* last change: $Author: hr $ $Date: 2007-06-27 22:24:05 $
|
2004-08-23 08:04:42 +00:00
|
|
|
*
|
2005-09-07 18:43:09 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2004-08-23 08:04:42 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-07 18:43:09 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2004-08-23 08:04:42 +00:00
|
|
|
*
|
2005-09-07 18:43:09 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2004-08-23 08:04:42 +00:00
|
|
|
*
|
2005-09-07 18:43:09 +00:00
|
|
|
* This library 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 for more details.
|
2004-08-23 08:04:42 +00:00
|
|
|
*
|
2005-09-07 18:43:09 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2004-08-23 08:04:42 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2004-11-26 20:07:02 +00:00
|
|
|
#include <cstdio>
|
|
|
|
|
2007-06-27 21:24:05 +00:00
|
|
|
#include <avmedia/mediawindow.hxx>
|
2004-08-23 08:04:42 +00:00
|
|
|
#include "mediawindow_impl.hxx"
|
|
|
|
#include "mediamisc.hxx"
|
|
|
|
#include "mediawindow.hrc"
|
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#include <svtools/pathoptions.hxx>
|
|
|
|
#include <sfx2/filedlghelper.hxx>
|
|
|
|
|
|
|
|
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
|
|
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_MEDIA_XMANAGER_HPP_
|
|
|
|
#include <com/sun/star/media/XManager.hpp>
|
|
|
|
#endif
|
2006-10-12 10:26:19 +00:00
|
|
|
#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
|
2004-08-23 08:04:42 +00:00
|
|
|
|
2005-03-23 11:29:58 +00:00
|
|
|
#define AVMEDIA_FRAMEGRABBER_DEFAULTFRAME_MEDIATIME 3.0
|
|
|
|
|
2004-08-23 08:04:42 +00:00
|
|
|
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() );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2006-06-19 12:59:52 +00:00
|
|
|
void MediaWindow::MouseMove( const MouseEvent& /* rMEvt */ )
|
2004-08-23 08:04:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
2006-06-19 12:59:52 +00:00
|
|
|
void MediaWindow::MouseButtonDown( const MouseEvent& /* rMEvt */ )
|
2004-08-23 08:04:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
2006-06-19 12:59:52 +00:00
|
|
|
void MediaWindow::MouseButtonUp( const MouseEvent& /* rMEvt */ )
|
2004-08-23 08:04:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2006-06-19 12:59:52 +00:00
|
|
|
void MediaWindow::KeyInput( const KeyEvent& /* rKEvt */ )
|
2004-08-23 08:04:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2006-06-19 12:59:52 +00:00
|
|
|
void MediaWindow::KeyUp( const KeyEvent& /* rKEvt */ )
|
2004-08-23 08:04:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2006-06-19 12:59:52 +00:00
|
|
|
void MediaWindow::Command( const CommandEvent& /* rCEvt */ )
|
2004-08-23 08:04:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2006-06-19 12:59:52 +00:00
|
|
|
sal_Int8 MediaWindow::AcceptDrop( const AcceptDropEvent& /* rEvt */ )
|
2004-08-23 08:04:42 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2006-06-19 12:59:52 +00:00
|
|
|
sal_Int8 MediaWindow::ExecuteDrop( const ExecuteDropEvent& /* rEvt */ )
|
2004-08-23 08:04:42 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2006-06-19 12:59:52 +00:00
|
|
|
void MediaWindow::StartDrag( sal_Int8 /* nAction */, const Point& /* rPosPixel */ )
|
2004-08-23 08:04:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
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",
|
|
|
|
"Quicktime Video", "mov",
|
|
|
|
"Vivo Video", "viv",
|
|
|
|
"WAVE Audio", "wav" };
|
|
|
|
|
2006-06-19 12:59:52 +00:00
|
|
|
unsigned int i;
|
|
|
|
for( i = 0; i < ( sizeof( pFilters ) / sizeof( char* ) ); i += 2 )
|
2004-08-23 08:04:42 +00:00
|
|
|
{
|
|
|
|
rFilterNameVector.push_back( ::std::make_pair< ::rtl::OUString, ::rtl::OUString >(
|
|
|
|
::rtl::OUString::createFromAscii( pFilters[ i ] ),
|
|
|
|
::rtl::OUString::createFromAscii( pFilters[ i + 1 ] ) ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2006-06-19 12:59:52 +00:00
|
|
|
bool MediaWindow::executeMediaURLDialog( Window* /* pParent */, ::rtl::OUString& rURL, bool bInsertDialog )
|
2004-08-23 08:04:42 +00:00
|
|
|
{
|
2006-10-12 10:26:19 +00:00
|
|
|
::sfx2::FileDialogHelper aDlg( com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0 );
|
2004-08-23 08:04:42 +00:00
|
|
|
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 );
|
|
|
|
|
2006-06-19 12:59:52 +00:00
|
|
|
unsigned int i;
|
|
|
|
for( i = 0; i < aFilters.size(); ++i )
|
2004-08-23 08:04:42 +00:00
|
|
|
{
|
|
|
|
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 );
|
|
|
|
|
2006-06-19 12:59:52 +00:00
|
|
|
for( i = 0; i < aFilters.size(); ++i )
|
2004-08-23 08:04:42 +00:00
|
|
|
{
|
|
|
|
::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
|
|
|
|
{
|
|
|
|
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 );
|
|
|
|
|
2006-06-19 12:59:52 +00:00
|
|
|
unsigned int i;
|
|
|
|
for( i = 0; ( i < aFilters.size() ) && !bRet; ++i )
|
2004-08-23 08:04:42 +00:00
|
|
|
{
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
2005-03-23 11:29:58 +00:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2004-08-23 08:04:42 +00:00
|
|
|
} // namespace avemdia
|