sw a11y: clang-format SidebarWinAccessible code
[LibreOffice.git] / slideshow / source / inc / soundplayer.hxx
blob3914a08a2725ab681583a56f49a6df44e2a9d200
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/XPlayer.hpp>
27 #include <avmedia/mediaitem.hxx>
29 #include <memory>
31 #include "pauseeventhandler.hxx"
32 #include "disposable.hxx"
33 #include "eventmultiplexer.hxx"
36 /* Definition of SoundPlayer class */
38 namespace slideshow::internal
40 class MediaFileManager;
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,
68 MediaFileManager& rMediaFileManager);
70 virtual ~SoundPlayer() override;
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;
81 bool startPlayback();
82 bool stopPlayback();
83 bool isPlaying() const;
85 void setPlaybackLoop( bool bLoop );
87 // PauseEventHandler:
88 virtual bool handlePause( bool bPauseShow ) override;
90 // Disposable
91 virtual void dispose() override;
93 private:
94 SoundPlayer(
95 EventMultiplexer & rEventMultiplexer,
96 const OUString& rSoundURL,
97 const css::uno::Reference< css::uno::XComponentContext>& rComponentContext,
98 MediaFileManager & rMediaFileManager);
100 EventMultiplexer & mrEventMultiplexer;
101 // TODO(Q3): obsolete when boost::enable_shared_ptr_from_this
102 // is available
103 ::std::shared_ptr<SoundPlayer> mThis;
104 // Temp file for package url.
105 ::std::shared_ptr<::avmedia::MediaTempFile> mpMediaTempFile;
106 css::uno::Reference< css::media::XPlayer > mxPlayer;
109 typedef ::std::shared_ptr< SoundPlayer > SoundPlayerSharedPtr;
113 #endif // INCLUDED_SLIDESHOW_SOURCE_INC_SOUNDPLAYER_HXX
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */