1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: mediaplayer.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <avmedia/mediaplayer.hxx>
32 #include <avmedia/mediawindow.hxx>
33 #include <avmedia/mediaitem.hxx>
34 #include "mediamisc.hxx"
35 #include "mediacontrol.hrc"
36 #include "helpids.hrc"
38 #include <svtools/stritem.hxx>
39 #include <sfx2/app.hxx>
40 #include <sfx2/sfxsids.hrc>
41 #include <sfx2/bindings.hxx>
42 #include <sfx2/dispatch.hxx>
51 MediaPlayer::MediaPlayer( Window
* _pParent
, USHORT nId
, SfxBindings
* _pBindings
, SfxChildWinInfo
* pInfo
) :
52 SfxChildWindow( _pParent
, nId
)
54 pWindow
= new MediaFloater( _pBindings
, this, _pParent
);
55 eChildAlignment
= SFX_ALIGN_NOALIGNMENT
;
56 static_cast< MediaFloater
* >( pWindow
)->Initialize( pInfo
);
59 // -----------------------------------------------------------------------------
61 MediaPlayer::~MediaPlayer()
65 // -----------------------------------------------------------------------------
67 SFX_IMPL_DOCKINGWINDOW( MediaPlayer
, SID_AVMEDIA_PLAYER
)
73 MediaFloater::MediaFloater( SfxBindings
* _pBindings
, SfxChildWindow
* pCW
, Window
* pParent
) :
74 SfxDockingWindow( _pBindings
, pCW
, pParent
, WB_CLOSEABLE
| WB_MOVEABLE
| WB_SIZEABLE
| WB_DOCKABLE
),
75 mpMediaWindow( new MediaWindow( this, true ) )
77 const Size
aSize( 378, 256 );
79 SetPosSizePixel( Point( 0, 0 ), aSize
);
80 SetMinOutputSizePixel( aSize
);
81 SetText( String( AVMEDIA_RESID( AVMEDIA_STR_MEDIAPLAYER
) ) );
83 mpMediaWindow
->show();
86 // -----------------------------------------------------------------------------
88 MediaFloater::~MediaFloater()
94 // -----------------------------------------------------------------------------
96 void MediaFloater::implInit()
100 // -------------------------------------------------------------------------
102 void MediaFloater::Resize()
104 SfxDockingWindow::Resize();
107 mpMediaWindow
->setPosSize( Rectangle( Point(), GetOutputSizePixel() ) );
110 // -----------------------------------------------------------------------------
112 void MediaFloater::ToggleFloatingMode()
114 ::avmedia::MediaItem aRestoreItem
;
116 mpMediaWindow
->updateMediaItem( aRestoreItem
);
117 delete mpMediaWindow
;
118 mpMediaWindow
= NULL
;
120 SfxDockingWindow::ToggleFloatingMode();
122 mpMediaWindow
= new MediaWindow( this, true );
124 mpMediaWindow
->setPosSize( Rectangle( Point(), GetOutputSizePixel() ) );
125 mpMediaWindow
->executeMediaItem( aRestoreItem
);
127 Window
* pWindow
= mpMediaWindow
->getWindow();
130 pWindow
->SetHelpId( HID_AVMEDIA_PLAYERWINDOW
);
132 mpMediaWindow
->show();
135 // -----------------------------------------------------------------------------
137 void MediaFloater::setURL( const ::rtl::OUString
& rURL
, bool bPlayImmediately
)
141 mpMediaWindow
->setURL( rURL
);
143 if( mpMediaWindow
->isValid() && bPlayImmediately
)
144 mpMediaWindow
->start();
148 // -----------------------------------------------------------------------------
150 const ::rtl::OUString
& MediaFloater::getURL() const
152 static const ::rtl::OUString aEmptyStr
;
153 return( mpMediaWindow
? mpMediaWindow
->getURL() : aEmptyStr
);
156 // -----------------------------------------------------------------------------
158 void MediaFloater::dispatchCurrentURL()
160 SfxDispatcher
* pDispatcher
= GetBindings().GetDispatcher();
164 const SfxStringItem
aMediaURLItem( SID_INSERT_AVMEDIA
, getURL() );
165 pDispatcher
->Execute( SID_INSERT_AVMEDIA
, SFX_CALLMODE_RECORD
, &aMediaURLItem
, 0L );