LibreOffice Module avmedia (master) 1
mediaplayer.cxx
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
22#include <avmedia/mediaitem.hxx>
23#include <mediamisc.hxx>
24#include <strings.hrc>
25#include <helpids.h>
26
27#include <svl/stritem.hxx>
28#include <sfx2/sfxsids.hrc>
29#include <sfx2/bindings.hxx>
30#include <sfx2/dispatch.hxx>
31
32namespace avmedia
33{
34
35MediaPlayer::MediaPlayer( vcl::Window* _pParent, sal_uInt16 nId, SfxBindings* _pBindings, SfxChildWinInfo* pInfo ) :
36 SfxChildWindow( _pParent, nId )
37{
38 SetWindow( VclPtr<MediaFloater>::Create( _pBindings, this, _pParent ) );
39 static_cast< MediaFloater* >( GetWindow() )->Initialize( pInfo );
40};
41
42
44{
45}
46
47
48SFX_IMPL_DOCKINGWINDOW_WITHID( MediaPlayer, SID_AVMEDIA_PLAYER )
49
50
51MediaFloater::MediaFloater( SfxBindings* _pBindings, SfxChildWindow* pCW, vcl::Window* pParent ) :
52 SfxDockingWindow( _pBindings, pCW, pParent, WB_CLOSEABLE | WB_MOVEABLE | WB_SIZEABLE | WB_DOCKABLE ),
53 mpMediaWindow( new MediaWindow( this, true ) )
54{
55 const Size aSize( mpMediaWindow->getPreferredSize() );
56
57 SetPosSizePixel( Point( 0, 0 ), aSize );
58 SetMinOutputSizePixel( aSize );
59 SetText( AvmResId( AVMEDIA_STR_MEDIAPLAYER ) );
60 mpMediaWindow->show();
61}
62
63
65{
66 disposeOnce();
67}
68
70{
71 if (IsFloatingMode())
72 {
73 Show(false, ShowFlags::NoFocusChange);
74 SetFloatingMode(false);
75 }
76 mpMediaWindow.reset();
78}
79
81{
83
84 if( mpMediaWindow )
85 mpMediaWindow->setPosSize( tools::Rectangle( Point(), GetOutputSizePixel() ) );
86}
87
89{
90 ::avmedia::MediaItem aRestoreItem;
91
92 if (mpMediaWindow)
93 mpMediaWindow->updateMediaItem( aRestoreItem );
94 mpMediaWindow.reset();
95
97
98 if (isDisposed())
99 return;
100
101 mpMediaWindow.reset( new MediaWindow( this, true ) );
102
103 mpMediaWindow->setPosSize( tools::Rectangle( Point(), GetOutputSizePixel() ) );
104 mpMediaWindow->executeMediaItem( aRestoreItem );
105
106 vcl::Window* pWindow = mpMediaWindow->getWindow();
107
108 if( pWindow )
110
111 mpMediaWindow->show();
112}
113
114
115void MediaFloater::setURL( const OUString& rURL, const OUString& rReferer, bool bPlayImmediately )
116{
117 if( mpMediaWindow )
118 {
119 mpMediaWindow->setURL( rURL, rReferer );
120
121 if( mpMediaWindow->isValid() && bPlayImmediately )
122 mpMediaWindow->start();
123 }
124}
125
126
128{
129 SfxDispatcher* pDispatcher = GetBindings().GetDispatcher();
130
131 if( pDispatcher )
132 {
133 OUString url;
134 if (mpMediaWindow != nullptr) {
135 url = mpMediaWindow->getURL();
136 }
137 const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, url );
138 pDispatcher->ExecuteList(SID_INSERT_AVMEDIA, SfxCallMode::RECORD,
139 { &aMediaURLItem });
140 }
141}
142
143} // namespace avmedia
144
145/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxDispatcher * GetDispatcher() const
vcl::Window * GetWindow() const
void SetWindow(const VclPtr< vcl::Window > &p)
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
virtual void Resize() override
SfxBindings & GetBindings() const
virtual void ToggleFloatingMode() override
virtual void dispose() override
virtual void dispose() override
Definition: mediaplayer.cxx:69
virtual void Resize() override
Definition: mediaplayer.cxx:80
std::unique_ptr< MediaWindow > mpMediaWindow
Definition: mediaplayer.hxx:58
void setURL(const OUString &rURL, const OUString &rReferer, bool bPlayImmediately)
virtual void ToggleFloatingMode() override
Definition: mediaplayer.cxx:88
virtual ~MediaFloater() override
Definition: mediaplayer.cxx:64
MediaPlayer(vcl::Window *, sal_uInt16, SfxBindings *, SfxChildWinInfo *)
Definition: mediaplayer.cxx:35
virtual ~MediaPlayer() override
Definition: mediaplayer.cxx:43
void SetHelpId(const OUString &)
virtual void SetText(const OUString &rStr) override
SFX_IMPL_DOCKINGWINDOW_WITHID(SvxFontWorkChildWindow, SID_FONTWORK)
constexpr OUStringLiteral HID_AVMEDIA_PLAYERWINDOW
Definition: helpids.h:34
OUString AvmResId(TranslateId aId)
Definition: mediamisc.hxx:36
sal_Int16 nId