1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
12 #include <sal/config.h>
14 #include <QtMultimedia/QMediaPlayer>
15 #include <QtWidgets/QWidget>
17 #include <com/sun/star/lang/XServiceInfo.hpp>
18 #include <com/sun/star/media/XPlayer.hpp>
19 #include <com/sun/star/media/XPlayerNotifier.hpp>
20 #include <comphelper/multicontainer2.hxx>
21 #include <cppuhelper/compbase.hxx>
22 #include <cppuhelper/basemutex.hxx>
26 typedef cppu::WeakComponentImplHelper
<css::media::XPlayer
, css::media::XPlayerNotifier
,
27 css::lang::XServiceInfo
>
30 class QtPlayer final
: public QObject
, public cppu::BaseMutex
, public QtPlayer_BASE
38 bool create(const OUString
& rURL
);
41 virtual void SAL_CALL
start() override
;
42 virtual void SAL_CALL
stop() override
;
43 virtual sal_Bool SAL_CALL
isPlaying() override
;
44 virtual double SAL_CALL
getDuration() override
;
45 virtual void SAL_CALL
setMediaTime(double fTime
) override
;
46 virtual double SAL_CALL
getMediaTime() override
;
47 virtual void SAL_CALL
setPlaybackLoop(sal_Bool bSet
) override
;
48 virtual sal_Bool SAL_CALL
isPlaybackLoop() override
;
49 virtual void SAL_CALL
setVolumeDB(sal_Int16 nVolumeDB
) override
;
50 virtual sal_Int16 SAL_CALL
getVolumeDB() override
;
51 virtual void SAL_CALL
setMute(sal_Bool bSet
) override
;
52 virtual sal_Bool SAL_CALL
isMute() override
;
53 virtual css::awt::Size SAL_CALL
getPreferredPlayerWindowSize() override
;
54 virtual css::uno::Reference
<css::media::XPlayerWindow
>
55 SAL_CALL
createPlayerWindow(const css::uno::Sequence
<css::uno::Any
>& rArgs
) override
;
56 virtual css::uno::Reference
<css::media::XFrameGrabber
> SAL_CALL
createFrameGrabber() override
;
60 addPlayerListener(const css::uno::Reference
<css::media::XPlayerListener
>& rListener
) override
;
61 virtual void SAL_CALL
removePlayerListener(
62 const css::uno::Reference
<css::media::XPlayerListener
>& rListener
) override
;
65 virtual OUString SAL_CALL
getImplementationName() override
;
66 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
67 virtual css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames() override
;
69 virtual void SAL_CALL
disposing() final override
;
72 std::unique_ptr
<QMediaPlayer
> m_xMediaPlayer
;
73 comphelper::OMultiTypeInterfaceContainerHelper2 m_lListener
;
75 // area to use for the player widget
76 css::awt::Rectangle m_aPlayerWidgetRect
;
78 QWidget
* m_pMediaWidgetParent
;
80 void createMediaPlayerWidget();
84 void uninstallNotify();
85 void notifyListeners();
86 void notifyIfReady(QMediaPlayer::MediaStatus eStatus
);
89 } // namespace avmedia::qt
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */