1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SLIDESHOW_SOURCE_INC_SOUNDPLAYER_HXX
21 #define INCLUDED_SLIDESHOW_SOURCE_INC_SOUNDPLAYER_HXX
23 #include <rtl/ustring.hxx>
25 #include <com/sun/star/uno/XComponentContext.hpp>
26 #include <com/sun/star/media/XManager.hpp>
27 #include <com/sun/star/media/XPlayer.hpp>
29 #include <boost/shared_ptr.hpp>
31 #include "pauseeventhandler.hxx"
32 #include "disposable.hxx"
33 #include "eventmultiplexer.hxx"
36 /* Definition of SoundPlayer class */
42 /** Little class that plays a sound from a URL.
44 Must be explicitly disposed (as long as enable_shared_ptr_from_this
47 class SoundPlayer
: public PauseEventHandler
,
51 /** Create a sound player object.
56 @param rComponentContext
57 Reference to a component context, used to create the
60 @throws ::com::sun::star::lang::NoSupportException, if
61 the sound file is invalid, or not supported by the
64 static ::boost::shared_ptr
<SoundPlayer
> create(
65 EventMultiplexer
& rEventMultiplexer
,
66 const OUString
& rSoundURL
,
67 const ::com::sun::star::uno::Reference
<
68 ::com::sun::star::uno::XComponentContext
>& rComponentContext
);
70 virtual ~SoundPlayer();
72 /** Query duration of sound playback.
74 If the sound is already playing, this method
75 returns the remaining playback time.
77 @return the playback duration in seconds.
79 double getDuration() const;
84 void setPlaybackLoop( bool bLoop
);
87 virtual bool handlePause( bool bPauseShow
) SAL_OVERRIDE
;
90 virtual void dispose() SAL_OVERRIDE
;
94 EventMultiplexer
& rEventMultiplexer
,
95 const OUString
& rSoundURL
,
96 const ::com::sun::star::uno::Reference
<
97 ::com::sun::star::uno::XComponentContext
>& rComponentContext
);
99 EventMultiplexer
& mrEventMultiplexer
;
100 // TODO(Q3): obsolete when boost::enable_shared_ptr_from_this
102 ::boost::shared_ptr
<SoundPlayer
> mThis
;
103 ::com::sun::star::uno::Reference
< ::com::sun::star::media::XPlayer
> mxPlayer
;
106 typedef ::boost::shared_ptr
< SoundPlayer
> SoundPlayerSharedPtr
;
110 #endif // INCLUDED_SLIDESHOW_SOURCE_INC_SOUNDPLAYER_HXX
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */