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