summaryrefslogtreecommitdiff
path: root/sd/source/ui/dlg/filedlg.cxx
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2008-03-07 15:26:00 +0000
committerKurt Zenker <kz@openoffice.org>2008-03-07 15:26:00 +0000
commit98ebfbe399f955463366e548ebe6837c52c0cb03 (patch)
tree1ca864ba8a72386fd14c240358be5ddc358f3b77 /sd/source/ui/dlg/filedlg.cxx
parentf571629787b5c6edef6a46931938e08feca5a39d (diff)
INTEGRATION: CWS unifysound01_DEV300 (1.17.66); FILE MERGED
2008/01/14 17:27:25 cmc 1.17.66.3: #i81144# use throw varient to pick up on failure to find any backend 2007/11/27 12:24:48 cmc 1.17.66.2: #i81144# windows sound seems seems a little different to the java one 2007/08/30 08:27:59 cmc 1.17.66.1: #i81144# move filepicker from vcl sound to avmedia sound
Diffstat (limited to 'sd/source/ui/dlg/filedlg.cxx')
-rw-r--r--sd/source/ui/dlg/filedlg.cxx91
1 files changed, 44 insertions, 47 deletions
diff --git a/sd/source/ui/dlg/filedlg.cxx b/sd/source/ui/dlg/filedlg.cxx
index c5844c9383e9..ba5697be152d 100644
--- a/sd/source/ui/dlg/filedlg.cxx
+++ b/sd/source/ui/dlg/filedlg.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: filedlg.cxx,v $
*
- * $Revision: 1.17 $
+ * $Revision: 1.18 $
*
- * last change: $Author: hr $ $Date: 2007-06-27 15:40:41 $
+ * last change: $Author: kz $ $Date: 2008-03-07 16:26:00 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -78,9 +78,6 @@
#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
#endif
-#ifndef _SOUND_HXX //autogen
-#include <vcl/sound.hxx>
-#endif
#ifndef _SV_MSGBOX_HXX
#include <vcl/msgbox.hxx>
#endif
@@ -107,6 +104,7 @@
#include <svx/impgrf.hxx>
+#include <avmedia/mediawindow.hxx>
#include "filedlg.hxx"
#include "sdresid.hxx"
#include "strings.hrc"
@@ -133,16 +131,18 @@ private:
css::uno::Reference< css::ui::dialogs::XFilePickerControlAccess > mxControlAccess;
- Sound maSound;
+ css::uno::Reference< css::media::XPlayer > mxPlayer;
ULONG mnPlaySoundEvent;
BOOL mbUsableSelection;
BOOL mbLabelPlaying;
- BOOL mbDuringPreparePlaying;
void CheckSelectionState();
DECL_LINK( PlayMusicHdl, void * );
- DECL_LINK( StopMusicHdl, void * );
+
+ Timer maUpdateTimer;
+
+ DECL_LINK( IsMusicStoppedHdl, void * );
public:
SdFileDialog_Imp( const short nDialogType, sal_Bool bUsableSelection );
@@ -182,16 +182,18 @@ void SAL_CALL SdFileDialog_Imp::ControlStateChanged( const css::ui::dialogs::Fil
// ------------------------------------------------------------------------
IMPL_LINK( SdFileDialog_Imp, PlayMusicHdl, void *, EMPTYARG )
{
+ maUpdateTimer.Stop();
mnPlaySoundEvent = 0;
- if( mbLabelPlaying )
+ if (mxPlayer.is())
{
- // switch from playing to not playing
-
- // reset, so that sound file gets unlocked
- maSound.Stop();
- maSound.SetSoundName( String() );
+ if (mxPlayer->isPlaying())
+ mxPlayer->stop();
+ mxPlayer.clear();
+ }
+ if( mbLabelPlaying )
+ {
try
{
mxControlAccess->setLabel( css::ui::dialogs::ExtendedFilePickerElementIds::PUSHBUTTON_PLAY,
@@ -208,28 +210,23 @@ IMPL_LINK( SdFileDialog_Imp, PlayMusicHdl, void *, EMPTYARG )
}
else
{
- // switch from not playing to playing of current file
- if( maSound.IsPlaying() )
+ rtl::OUString aUrl( GetPath() );
+ if ( aUrl.getLength() )
{
- // reset, so that sound file gets unlocked
- maSound.Stop();
- maSound.SetSoundName( String() );
- }
-
- INetURLObject aUrl( GetPath() );
- String aSoundFile( aUrl.GetMainURL( INetURLObject::NO_DECODE ) );
+ try
+ {
+ mxPlayer.set( avmedia::MediaWindow::createPlayer( aUrl ), css::uno::UNO_QUERY_THROW );
+ mxPlayer->start();
+ maUpdateTimer.SetTimeout( 100 );
+ maUpdateTimer.Start();
+ }
+ catch( css::uno::Exception& e )
+ {
+ (void)e;
+ mxPlayer.clear();
+ }
- if( aSoundFile.Len() > 0 && Sound::IsSoundFile(aSoundFile) )
- {
- maSound.SetNotifyHdl( LINK( this, SdFileDialog_Imp, StopMusicHdl ) );
- mbDuringPreparePlaying=TRUE;
- maSound.SetSoundName( aSoundFile );
- maSound.Play();
-
- ULONG nError = maSound.GetLastError();
- mbDuringPreparePlaying=FALSE;
- // guard against early stopping
- if( maSound.IsPlaying() && !nError)
+ if (mxPlayer.is())
{
try
{
@@ -245,11 +242,6 @@ IMPL_LINK( SdFileDialog_Imp, PlayMusicHdl, void *, EMPTYARG )
#endif
}
}
- else if(nError)
- {
- //reset error state of sound
- maSound.SetSoundName( String() );
- }
}
}
@@ -257,15 +249,19 @@ IMPL_LINK( SdFileDialog_Imp, PlayMusicHdl, void *, EMPTYARG )
}
// ------------------------------------------------------------------------
-IMPL_LINK( SdFileDialog_Imp, StopMusicHdl, void *, EMPTYARG )
+IMPL_LINK( SdFileDialog_Imp, IsMusicStoppedHdl, void *, EMPTYARG )
{
- if(mbDuringPreparePlaying)
- return( 0L ); //don't reset the error state of maSound during prepare playing
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ if (
+ mxPlayer.is() && mxPlayer->isPlaying() &&
+ mxPlayer->getMediaTime() < mxPlayer->getDuration()
+ )
+ {
+ maUpdateTimer.Start();
+ return 0L;
+ }
- // reset, so that sound file gets unlocked
- maSound.SetSoundName( String() );
if( mxControlAccess.is() )
{
@@ -315,9 +311,10 @@ SdFileDialog_Imp::SdFileDialog_Imp( const short nDialogType,
FileDialogHelper( nDialogType, 0 ),
mnPlaySoundEvent( 0 ),
mbUsableSelection( bUsableSelection ),
- mbLabelPlaying(FALSE),
- mbDuringPreparePlaying(FALSE)
+ mbLabelPlaying(FALSE)
{
+ maUpdateTimer.SetTimeoutHdl(LINK(this, SdFileDialog_Imp, IsMusicStoppedHdl));
+
css::uno::Reference < ::com::sun::star::ui::dialogs::XFilePicker > xFileDlg = GetFilePicker();
// get the control access