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>
28 #include <avmedia/mediaitem.hxx>
32 #include "pauseeventhandler.hxx"
33 #include "disposable.hxx"
34 #include "eventmultiplexer.hxx"
37 /* Definition of SoundPlayer class */
43 class MediaFileManager
;
45 /** Little class that plays a sound from a URL.
47 Must be explicitly disposed (as long as enable_shared_ptr_from_this
50 class SoundPlayer
: public PauseEventHandler
,
54 /** Create a sound player object.
59 @param rComponentContext
60 Reference to a component context, used to create the
63 @throws css::lang::NoSupportException, if
64 the sound file is invalid, or not supported by the
67 static ::std::shared_ptr
<SoundPlayer
> create(
68 EventMultiplexer
& rEventMultiplexer
,
69 const OUString
& rSoundURL
,
70 const css::uno::Reference
< css::uno::XComponentContext
>& rComponentContext
,
71 MediaFileManager
& rMediaFileManager
);
73 virtual ~SoundPlayer() override
;
75 /** Query duration of sound playback.
77 If the sound is already playing, this method
78 returns the remaining playback time.
80 @return the playback duration in seconds.
82 double getDuration() const;
86 bool isPlaying() const;
88 void setPlaybackLoop( bool bLoop
);
91 virtual bool handlePause( bool bPauseShow
) override
;
94 virtual void dispose() override
;
98 EventMultiplexer
& rEventMultiplexer
,
99 const OUString
& rSoundURL
,
100 const css::uno::Reference
< css::uno::XComponentContext
>& rComponentContext
,
101 MediaFileManager
& rMediaFileManager
);
103 EventMultiplexer
& mrEventMultiplexer
;
104 // TODO(Q3): obsolete when boost::enable_shared_ptr_from_this
106 ::std::shared_ptr
<SoundPlayer
> mThis
;
107 // Temp file for package url.
108 ::std::shared_ptr
<::avmedia::MediaTempFile
> mpMediaTempFile
;
109 css::uno::Reference
< css::media::XPlayer
> mxPlayer
;
112 typedef ::std::shared_ptr
< SoundPlayer
> SoundPlayerSharedPtr
;
116 #endif // INCLUDED_SLIDESHOW_SOURCE_INC_SOUNDPLAYER_HXX
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */