Bump version to 6.0-36
[LibreOffice.git] / slideshow / source / inc / soundplayer.hxx
blob82af088af4625fc9bb9c49d24ab15c71553a4ad8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <memory>
31 #include "pauseeventhandler.hxx"
32 #include "disposable.hxx"
33 #include "eventmultiplexer.hxx"
36 /* Definition of SoundPlayer class */
38 namespace slideshow
40 namespace internal
42 /** Little class that plays a sound from a URL.
43 TODO:
44 Must be explicitly disposed (as long as enable_shared_ptr_from_this
45 isn't available)!
47 class SoundPlayer : public PauseEventHandler,
48 public Disposable
50 public:
51 /** Create a sound player object.
53 @param rSoundURL
54 URL to a sound file.
56 @param rComponentContext
57 Reference to a component context, used to create the
58 needed services
60 @throws css::lang::NoSupportException, if
61 the sound file is invalid, or not supported by the
62 player service.
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;
80 bool startPlayback();
81 bool stopPlayback();
83 void setPlaybackLoop( bool bLoop );
85 // PauseEventHandler:
86 virtual bool handlePause( bool bPauseShow ) override;
88 // Disposable
89 virtual void dispose() override;
91 private:
92 SoundPlayer(
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
99 // is available
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: */