LibreOffice Module slideshow (master) 1
soundplayer.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_SLIDESHOW_SOURCE_INC_SOUNDPLAYER_HXX
21#define INCLUDED_SLIDESHOW_SOURCE_INC_SOUNDPLAYER_HXX
22
23#include <rtl/ustring.hxx>
24
25#include <com/sun/star/uno/XComponentContext.hpp>
26#include <com/sun/star/media/XPlayer.hpp>
27#include <avmedia/mediaitem.hxx>
28
29#include <memory>
30
31#include "pauseeventhandler.hxx"
32#include "disposable.hxx"
33#include "eventmultiplexer.hxx"
34
35
36/* Definition of SoundPlayer class */
37
38namespace slideshow::internal
39 {
40 class MediaFileManager;
41
48 public Disposable
49 {
50 public:
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);
69
70 virtual ~SoundPlayer() override;
71
79 double getDuration() const;
80
81 bool startPlayback();
82 bool stopPlayback();
83 bool isPlaying() const;
84
85 void setPlaybackLoop( bool bLoop );
86
87 // PauseEventHandler:
88 virtual bool handlePause( bool bPauseShow ) override;
89
90 // Disposable
91 virtual void dispose() override;
92
93 private:
95 EventMultiplexer & rEventMultiplexer,
96 const OUString& rSoundURL,
97 const css::uno::Reference< css::uno::XComponentContext>& rComponentContext,
98 MediaFileManager & rMediaFileManager);
99
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;
107 };
108
109 typedef ::std::shared_ptr< SoundPlayer > SoundPlayerSharedPtr;
110
111}
112
113#endif // INCLUDED_SLIDESHOW_SOURCE_INC_SOUNDPLAYER_HXX
114
115/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Disposable interface.
Definition: disposable.hxx:48
This class multiplexes user-activated and slide-show global events.
Interface for handling pause events.
Little class that plays a sound from a URL.
Definition: soundplayer.hxx:49
css::uno::Reference< css::media::XPlayer > mxPlayer
virtual void dispose() override
Dispose all object references.
Definition: soundplayer.cxx:63
virtual bool handlePause(bool bPauseShow) override
Handle the event.
Definition: soundplayer.cxx:58
::std::shared_ptr< SoundPlayer > mThis
::std::shared_ptr<::avmedia::MediaTempFile > mpMediaTempFile
SoundPlayer(EventMultiplexer &rEventMultiplexer, const OUString &rSoundURL, const css::uno::Reference< css::uno::XComponentContext > &rComponentContext, MediaFileManager &rMediaFileManager)
Definition: soundplayer.cxx:82
EventMultiplexer & mrEventMultiplexer
double getDuration() const
Query duration of sound playback.
static ::std::shared_ptr< SoundPlayer > create(EventMultiplexer &rEventMultiplexer, const OUString &rSoundURL, const css::uno::Reference< css::uno::XComponentContext > &rComponentContext, MediaFileManager &rMediaFileManager)
Create a sound player object.
Definition: soundplayer.cxx:42
::std::shared_ptr< SoundPlayer > SoundPlayerSharedPtr