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>
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 css::lang::NoSupportException, if
61 the sound file is invalid, or not supported by the
64 static ::std::shared_ptr
<SoundPlayer
> create(
65 EventMultiplexer
& rEventMultiplexer
,
66 const OUString
& rSoundURL
,
67 const css::uno::Reference
< css::uno::XComponentContext
>& rComponentContext
);
69 virtual ~SoundPlayer() override
;
71 /** Query duration of sound playback.
73 If the sound is already playing, this method
74 returns the remaining playback time.
76 @return the playback duration in seconds.
78 double getDuration() const;
83 void setPlaybackLoop( bool bLoop
);
86 virtual bool handlePause( bool bPauseShow
) override
;
89 virtual void dispose() override
;
93 EventMultiplexer
& rEventMultiplexer
,
94 const OUString
& rSoundURL
,
95 const css::uno::Reference
< css::uno::XComponentContext
>& rComponentContext
);
97 EventMultiplexer
& mrEventMultiplexer
;
98 // TODO(Q3): obsolete when boost::enable_shared_ptr_from_this
100 ::std::shared_ptr
<SoundPlayer
> mThis
;
101 css::uno::Reference
< css::media::XPlayer
> mxPlayer
;
104 typedef ::std::shared_ptr
< SoundPlayer
> SoundPlayerSharedPtr
;
108 #endif // INCLUDED_SLIDESHOW_SOURCE_INC_SOUNDPLAYER_HXX
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */