update dev300-m58
[ooovba.git] / slideshow / source / inc / soundplayer.hxx
blob89bce57fc61d35b3eeaef1cd75c69800e2216231
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: soundplayer.hxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef INCLUDED_SLIDESHOW_SOUNDPLAYER_HXX
32 #define INCLUDED_SLIDESHOW_SOUNDPLAYER_HXX
34 #include <rtl/ustring.hxx>
36 #include <com/sun/star/uno/XComponentContext.hpp>
37 #include <com/sun/star/media/XManager.hpp>
38 #include <com/sun/star/media/XPlayer.hpp>
40 #include <boost/shared_ptr.hpp>
42 #include "pauseeventhandler.hxx"
43 #include "disposable.hxx"
44 #include "eventmultiplexer.hxx"
47 /* Definition of SoundPlayer class */
49 namespace slideshow
51 namespace internal
53 /** Little class that plays a sound from a URL.
54 TODO:
55 Must be explicitly disposed (as long as enable_shared_ptr_from_this
56 isn't available)!
58 class SoundPlayer : public PauseEventHandler,
59 public Disposable
61 public:
62 /** Create a sound player object.
64 @param rSoundURL
65 URL to a sound file.
67 @param rComponentContext
68 Reference to a component context, used to create the
69 needed services
71 @throws ::com::sun::star::lang::NoSupportException, if
72 the sound file is invalid, or not supported by the
73 player service.
75 static ::boost::shared_ptr<SoundPlayer> create(
76 EventMultiplexer & rEventMultiplexer,
77 const ::rtl::OUString& rSoundURL,
78 const ::com::sun::star::uno::Reference<
79 ::com::sun::star::uno::XComponentContext>& rComponentContext );
81 virtual ~SoundPlayer();
83 /** Query duration of sound playback.
85 If the sound is already playing, this method
86 returns the remaining playback time.
88 @return the playback duration in seconds.
90 double getDuration() const;
92 bool startPlayback();
93 bool stopPlayback();
95 void setPlaybackLoop( bool bLoop );
97 // PauseEventHandler:
98 virtual bool handlePause( bool bPauseShow );
100 // Disposable
101 virtual void dispose();
103 private:
104 SoundPlayer(
105 EventMultiplexer & rEventMultiplexer,
106 const ::rtl::OUString& rSoundURL,
107 const ::com::sun::star::uno::Reference<
108 ::com::sun::star::uno::XComponentContext>& rComponentContext );
110 EventMultiplexer & mrEventMultiplexer;
111 // TODO(Q3): obsolete when boost::enable_shared_ptr_from_this
112 // is available
113 ::boost::shared_ptr<SoundPlayer> mThis;
114 ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > mxPlayer;
117 typedef ::boost::shared_ptr< SoundPlayer > SoundPlayerSharedPtr;
121 #endif /* INCLUDED_SLIDESHOW_SOUNDPLAYER_HXX */