Commit 3a3937f7 authored by Sergey Radionov's avatar Sergey Radionov Committed by Jean-Baptiste Kempf

Win32: NPAPI Fullscreen support

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent c9dfaf20
......@@ -28,6 +28,10 @@ LIBRARIES_libvlc = $(top_builddir)/src/libvlc.la \
if HAVE_WIN32
SOURCES_mozilla_common += \
vlc_win32_fullscreen.cpp \
vlc_win32_fullscreen.h
# Under Win32, Mozilla plugins need to be named NP******.DLL, but under Unix
# the common naming scheme is lib******plugin.so. Also, we need npwin.cpp
# under Win32 and npunix.cpp under Unix.
......
......@@ -41,3 +41,9 @@ BEGIN
VALUE "Translation", 0x409, 1252
END
END
3 BITMAP DISCARDABLE "pixmaps/defullscreen.bmp"
4 BITMAP DISCARDABLE "pixmaps/play.bmp"
5 BITMAP DISCARDABLE "pixmaps/pause.bmp"
6 BITMAP DISCARDABLE "pixmaps/volume.bmp"
7 BITMAP DISCARDABLE "pixmaps/volume-muted.bmp"
This diff is collapsed.
/*****************************************************************************
* vlc_win32_fullscreen.h: a VLC plugin for Mozilla
*****************************************************************************
* Copyright (C) 2002-2011 the VideoLAN team
* $Id$
*
* Authors: Sergey Radionov <rsatom@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef VLC_FULLSCREEN_H
#define VLC_FULLSCREEN_H
#ifdef _WIN32
///////////////////////
//VLCHolderWnd
///////////////////////
class VLCHolderWnd
{
public:
static void RegisterWndClassName(HINSTANCE hInstance);
static void UnRegisterWndClassName();
static VLCHolderWnd* CreateHolderWindow(HWND hParentWnd);
void DestroyWindow()
{::DestroyWindow(_hWnd);};
private:
static LPCTSTR getClassName(void) { return TEXT("VLC ActiveX Window Holder Class"); };
static LRESULT CALLBACK VLCHolderClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
private:
static HINSTANCE _hinstance;
static ATOM _holder_wndclass_atom;
private:
VLCHolderWnd(HWND hWnd)
:_hWnd(hWnd){};
public:
HWND getHWND() const {return _hWnd;}
private:
HWND _hWnd;
};
///////////////////////
//VLCFullScreenWnd
///////////////////////
class VLCWindowsManager;
class VLCFullScreenWnd
{
public:
static void RegisterWndClassName(HINSTANCE hInstance);
static void UnRegisterWndClassName();
static VLCFullScreenWnd* CreateFSWindow(VLCWindowsManager* WM);
void DestroyWindow()
{::DestroyWindow(_hWnd);};
private:
static LPCTSTR getClassName(void) { return TEXT("VLC ActiveX Fullscreen Class"); };
static LRESULT CALLBACK FSWndWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static LPCTSTR getControlsClassName(void) { return TEXT("VLC ActiveX Fullscreen Controls Class"); };
static LRESULT CALLBACK FSControlsWndWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
private:
static HINSTANCE _hinstance;
static ATOM _fullscreen_wndclass_atom;
static ATOM _fullscreen_controls_wndclass_atom;
private:
VLCFullScreenWnd(HWND hWnd, VLCWindowsManager* WM)
:_hWnd(hWnd), _WindowsManager(WM),
hControlsWnd(0), hToolTipWnd(0), hNewMessageBitmap(0), hFSButtonBitmap(0), hFSButton(0),
hPauseBitmap(0), hPlayBitmap(0), hPlayPauseButton(0), hVideoPosScroll(0),
hMuteButton(0), hVolumeBitmap(0), hVolumeMutedBitmap(0),
hVolumeSlider(0), Last_WM_MOUSEMOVE_lParam(0){};
~VLCFullScreenWnd();
private:
libvlc_media_player_t* getMD();
bool IsPlaying()
{
libvlc_media_player_t* p_md = getMD();
int is_playing = 0;
if( p_md ){
is_playing = libvlc_media_player_is_playing(p_md);
}
return is_playing!=0;
}
private:
void RegisterEvents();
void UnRegisterEvents();
void SetVideoPosScrollRangeByVideoLen();
void SyncVideoPosScrollPosWithVideoPos();
void SetVideoPos(float Pos); //0-start, 1-end
void SyncVolumeSliderWithVLCVolume();
void SetVLCVolumeBySliderPos(int CurScrollPos);
void NeedShowControls();
void NeedHideControls();
private:
void CreateToolTip();
private:
LPARAM Last_WM_MOUSEMOVE_lParam;
private:
VLCWindowsManager* _WindowsManager;
private:
HWND hControlsWnd;
HWND hToolTipWnd;
HICON hNewMessageBitmap;
HANDLE hFSButtonBitmap;
HWND hFSButton;
HANDLE hPauseBitmap;
HANDLE hPlayBitmap;
HWND hPlayPauseButton;
HWND hVideoPosScroll;
HANDLE hVolumeBitmap;
HANDLE hVolumeMutedBitmap;
HWND hMuteButton;
HWND hVolumeSlider;
private:
void SetVideoPosScrollPosByVideoPos(int CurPos);
static bool handle_position_changed_event_enabled;
static void handle_position_changed_event(const libvlc_event_t* event, void *param);
//static void handle_time_changed_event(const libvlc_event_t* event, void *param);
static void handle_input_state_event(const libvlc_event_t* event, void *param);
public:
HWND getHWND() const {return _hWnd;}
private:
HWND _hWnd;
int VideoPosShiftBits;
};
///////////////////////
//VLCWindowsManager
///////////////////////
class VLCWindowsManager
{
public:
VLCWindowsManager(HMODULE hModule);
~VLCWindowsManager();
void CreateWindows(HWND hWindowedParentWnd);
void DestroyWindows();
void LibVlcAttach(libvlc_media_player_t* p_md);
void LibVlcDetach();
void StartFullScreen();
void EndFullScreen();
void ToggleFullScreen();
bool IsFullScreen();
HMODULE getHModule() const {return _hModule;};
VLCHolderWnd* getHolderWnd() const {return _HolderWnd;}
VLCFullScreenWnd* getFullScreenWnd() const {return _FSWnd;}
libvlc_media_player_t* getMD() {return _p_md;}
public:
void setNewMessageFlag(bool Yes)
{_b_new_messages_flag = Yes;};
bool getNewMessageFlag() const
{return _b_new_messages_flag;};
private:
HMODULE _hModule;
HWND _hWindowedParentWnd;
libvlc_media_player_t* _p_md;
VLCHolderWnd* _HolderWnd;
VLCFullScreenWnd* _FSWnd;
bool _b_new_messages_flag;
};
#endif //_WIN32
#endif //VLC_FULLSCREEN_H
......@@ -46,6 +46,34 @@
#include <assert.h>
#include <stdlib.h>
#ifdef XP_WIN
#include "vlc_win32_fullscreen.h"
static HMODULE hDllModule= 0;
HMODULE DllGetModule()
{
return hDllModule;
};
extern "C"
BOOL WINAPI DllMain(HANDLE hModule, DWORD fdwReason, LPVOID lpReserved )
{
switch( fdwReason )
{
case DLL_PROCESS_ATTACH:
hDllModule = (HMODULE)hModule;
break;
default:
break;
}
return TRUE;
};
#endif
/*****************************************************************************
* utilitiy functions
*****************************************************************************/
......@@ -124,6 +152,7 @@ VlcPlugin::VlcPlugin( NPP instance, uint16_t mode ) :
psz_baseURL(NULL)
#if defined(XP_WIN)
,pf_wndproc(NULL)
,_WindowsManager(DllGetModule())
#endif
#if defined(XP_UNIX)
,i_width((unsigned)-1)
......@@ -510,6 +539,14 @@ VlcPlugin::~VlcPlugin()
libvlc_release(libvlc_instance);
}
void VlcPlugin::setWindow(const NPWindow &window)
{
npwindow = window;
#ifdef XP_WIN
_WindowsManager.CreateWindows((HWND)(getWindow().window));
#endif
};
/*****************************************************************************
* VlcPlugin playlist replacement methods
*****************************************************************************/
......@@ -523,8 +560,7 @@ void VlcPlugin::set_player_window()
// XXX FIXME insert appropriate call here
#endif
#ifdef XP_WIN
libvlc_media_player_set_hwnd(libvlc_media_player,
getWindow().window);
_WindowsManager.LibVlcAttach(libvlc_media_player);
#endif
}
......@@ -645,22 +681,47 @@ int VlcPlugin::playlist_count()
void VlcPlugin::toggle_fullscreen()
{
#ifdef XP_WIN
if(!get_fullscreen()){//now in windowed mode
set_fullscreen(true);
}
else if(get_fullscreen()){//now in fullscreen mode
set_fullscreen(false);
}
else {
//and what it meen?
}
#else
if( playlist_isplaying() )
libvlc_toggle_fullscreen(libvlc_media_player);
#endif
}
void VlcPlugin::set_fullscreen( int yes )
{
#ifdef XP_WIN
if(yes){
_WindowsManager.StartFullScreen();
}
else{
_WindowsManager.EndFullScreen();
}
#else
if( playlist_isplaying() )
libvlc_set_fullscreen(libvlc_media_player,yes);
#endif
}
int VlcPlugin::get_fullscreen()
{
#ifdef XP_WIN
return _WindowsManager.IsFullScreen();
#else
int r = 0;
if( playlist_isplaying() )
r = libvlc_get_fullscreen(libvlc_media_player);
return r;
#endif
}
bool VlcPlugin::player_has_vout()
......
......@@ -182,6 +182,10 @@ private:
void unask_for_event(event_t e);
};
#ifdef XP_WIN
HMODULE DllGetModule();
#include "vlc_win32_fullscreen.h"
#endif
class VlcPlugin
{
......@@ -209,8 +213,7 @@ public:
char* getAbsoluteURL(const char *url);
NPWindow& getWindow()
{ return npwindow; };
void setWindow(const NPWindow &window)
{ npwindow = window; };
void setWindow(const NPWindow &window);
NPClass* getScriptClass()
{ return p_scriptClass; };
......@@ -333,6 +336,7 @@ private:
NPWindow npwindow;
#if defined(XP_WIN)
WNDPROC pf_wndproc;
VLCWindowsManager _WindowsManager;
#endif
#if defined(XP_UNIX)
unsigned int i_width, i_height;
......
......@@ -753,6 +753,20 @@ static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpa
EndPaint( p_hwnd, &paintstruct );
return 0L;
}
case WM_SIZE:{
int new_client_width = LOWORD(lpar);
int new_client_height = HIWORD(lpar);
//first child will be resized to client area
HWND hChildWnd = GetWindow(p_hwnd, GW_CHILD);
if(hChildWnd){
MoveWindow(hChildWnd, 0, 0, new_client_width, new_client_height, FALSE);
}
return 0L;
}
case WM_LBUTTONDBLCLK:{
p_plugin->toggle_fullscreen();
return 0L;
}
default:
/* delegate to default handler */
return CallWindowProc( p_plugin->getWindowProc(), p_hwnd,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment