vlc_win32_fullscreen.h 5.78 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
/*****************************************************************************
 * 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)
        : Last_WM_MOUSEMOVE_lParam(0),_WindowsManager(WM), hControlsWnd(0), hToolTipWnd(0),
         hNewMessageBitmap(0), hFSButtonBitmap(0), hFSButton(0),
         hPauseBitmap(0), hPlayBitmap(0), hPlayPauseButton(0), hVideoPosScroll(0),
         hVolumeBitmap(0), hVolumeMutedBitmap(0),hMuteButton(0),
         hVolumeSlider(0), _hWnd(hWnd) {};

    ~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