]> git.sesse.net Git - vlc/blobdiff - activex/plugin.cpp
Fix playlist_item_t.i_id vs input_item_t.i_id mess in HTTP interface. (Looks like...
[vlc] / activex / plugin.cpp
index 4dceeeaa8f1a6f627fa886c48bbfc17e7c6fe648..65c15eb8512f8f36bd0f61cf44d48186a87a3498 100644 (file)
@@ -351,6 +351,7 @@ HRESULT VLCPlugin::onInit(void)
         _b_mute = FALSE;
         _i_volume = 50;
         _i_time   = 0;
+        _i_backcolor = 0;
         // set default/preferred size (320x240) pixels in HIMETRIC
         HDC hDC = CreateDevDC(NULL);
         _extent.cx = 320;
@@ -483,20 +484,6 @@ HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc)
         if( _b_autoloop )
             ppsz_argv[ppsz_argc++] = "--loop";
 
-        if( IsDebuggerPresent() )
-        {
-            /*
-            ** VLC default threading mechanism is designed to be as compatible
-            ** with POSIX as possible. However when debugged on win32, threads
-            ** lose signals and eventually VLC get stuck during initialization.
-            ** threading support can be configured to be more debugging friendly
-            ** but it will be less compatible with POSIX.
-            ** This is done by initializing with the following options:
-            */
-            ppsz_argv[ppsz_argc++] = "--fast-mutex";
-            ppsz_argv[ppsz_argc++] = "--win9x-cv-method=1";
-        }
-
         _p_libvlc = libvlc_new(ppsz_argc, ppsz_argv, NULL);
         if( NULL == _p_libvlc )
         {
@@ -573,6 +560,12 @@ HRESULT VLCPlugin::onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID)
     switch( dispID )
     {
         case DISPID_AMBIENT_BACKCOLOR:
+            VariantInit(&v);
+            V_VT(&v) = VT_I4;
+            if( SUCCEEDED(GetObjectProperty(pContainer, dispID, v)) )
+            {
+                setBackColor(V_I4(&v));
+            }
             break;
         case DISPID_AMBIENT_DISPLAYNAME:
             break;
@@ -796,6 +789,19 @@ void VLCPlugin::setVolume(int volume)
     }
 };
 
+void VLCPlugin::setBackColor(OLE_COLOR backcolor)
+{
+    if( _i_backcolor != backcolor )
+    {
+        _i_backcolor = backcolor;
+        if( isInPlaceActive() )
+        {
+
+        }
+        setDirty(TRUE);
+    }
+};
+
 void VLCPlugin::setTime(int seconds)
 {
     if( seconds < 0 )
@@ -806,11 +812,11 @@ void VLCPlugin::setTime(int seconds)
         setStartTime(_i_time);
         if( isRunning() )
         {
-            libvlc_input_t *p_input = libvlc_playlist_get_input(_p_libvlc, NULL);
-            if( NULL != p_input )
+            libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(_p_libvlc, NULL);
+            if( NULL != p_md )
             {
-                libvlc_input_set_time(p_input, _i_time, NULL);
-                libvlc_input_free(p_input);
+                libvlc_media_instance_set_time(p_md, _i_time, NULL);
+                libvlc_media_instance_release(p_md);
             }
         }
     }
@@ -836,57 +842,80 @@ void VLCPlugin::onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev,
         long height = lprcBounds->bottom-lprcBounds->top;
 
         RECT bounds = { lprcBounds->left, lprcBounds->top, lprcBounds->right, lprcBounds->bottom };
-        FillRect(hdcDraw, &bounds, (HBRUSH)GetStockObject(WHITE_BRUSH));
 
-        LPPICTURE pict = getPicture();
-        if( NULL != pict )
+        if( isUserMode() )
         {
-            OLE_XSIZE_HIMETRIC picWidth;
-            OLE_YSIZE_HIMETRIC picHeight;
-
-            pict->get_Width(&picWidth);
-            pict->get_Height(&picHeight);
-
-            SIZEL picSize = { picWidth, picHeight };
-
-            if( NULL != hicTargetDev )
+            /* VLC is in user mode, just draw background color */
+            COLORREF colorref = RGB(0, 0, 0);
+            OleTranslateColor(_i_backcolor, (HPALETTE)GetStockObject(DEFAULT_PALETTE), &colorref);
+            if( colorref != RGB(0, 0, 0) )
             {
-                DPFromHimetric(hicTargetDev, (LPPOINT)&picSize, 1);
+                /* custom background */
+                HBRUSH colorbrush = CreateSolidBrush(colorref);
+                FillRect(hdcDraw, &bounds, colorbrush);
+                DeleteObject((HANDLE)colorbrush);
             }
-            else if( NULL != (hicTargetDev = CreateDevDC(ptd)) )
+            else
             {
-                DPFromHimetric(hicTargetDev, (LPPOINT)&picSize, 1);
-                DeleteDC(hicTargetDev);
+                /* black background */
+                FillRect(hdcDraw, &bounds, (HBRUSH)GetStockObject(BLACK_BRUSH));
             }
+        }
+        else
+        {
+            /* VLC is in design mode, draw the VLC logo */
+            FillRect(hdcDraw, &bounds, (HBRUSH)GetStockObject(WHITE_BRUSH));
 
-            if( picSize.cx > width-4 )
-                picSize.cx = width-4;
-            if( picSize.cy > height-4 )
-                picSize.cy = height-4;
+            LPPICTURE pict = getPicture();
+            if( NULL != pict )
+            {
+                OLE_XSIZE_HIMETRIC picWidth;
+                OLE_YSIZE_HIMETRIC picHeight;
 
-            LONG dstX = lprcBounds->left+(width-picSize.cx)/2;
-            LONG dstY = lprcBounds->top+(height-picSize.cy)/2;
+                pict->get_Width(&picWidth);
+                pict->get_Height(&picHeight);
 
-            if( NULL != lprcWBounds )
-            {
-                RECT wBounds = { lprcWBounds->left, lprcWBounds->top, lprcWBounds->right, lprcWBounds->bottom };
-                pict->Render(hdcDraw, dstX, dstY, picSize.cx, picSize.cy,
-                        0L, picHeight, picWidth, -picHeight, &wBounds);
-            }
-            else 
-                pict->Render(hdcDraw, dstX, dstY, picSize.cx, picSize.cy,
-                        0L, picHeight, picWidth, -picHeight, NULL);
+                SIZEL picSize = { picWidth, picHeight };
 
-            pict->Release();
-        }
+                if( NULL != hicTargetDev )
+                {
+                    DPFromHimetric(hicTargetDev, (LPPOINT)&picSize, 1);
+                }
+                else if( NULL != (hicTargetDev = CreateDevDC(ptd)) )
+                {
+                    DPFromHimetric(hicTargetDev, (LPPOINT)&picSize, 1);
+                    DeleteDC(hicTargetDev);
+                }
+
+                if( picSize.cx > width-4 )
+                    picSize.cx = width-4;
+                if( picSize.cy > height-4 )
+                    picSize.cy = height-4;
+
+                LONG dstX = lprcBounds->left+(width-picSize.cx)/2;
+                LONG dstY = lprcBounds->top+(height-picSize.cy)/2;
+
+                if( NULL != lprcWBounds )
+                {
+                    RECT wBounds = { lprcWBounds->left, lprcWBounds->top, lprcWBounds->right, lprcWBounds->bottom };
+                    pict->Render(hdcDraw, dstX, dstY, picSize.cx, picSize.cy,
+                            0L, picHeight, picWidth, -picHeight, &wBounds);
+                }
+                else 
+                    pict->Render(hdcDraw, dstX, dstY, picSize.cx, picSize.cy,
+                            0L, picHeight, picWidth, -picHeight, NULL);
 
-        SelectObject(hdcDraw, GetStockObject(BLACK_BRUSH));
+                pict->Release();
+            }
 
-        MoveToEx(hdcDraw, bounds.left, bounds.top, NULL);
-        LineTo(hdcDraw, bounds.left+width-1, bounds.top);
-        LineTo(hdcDraw, bounds.left+width-1, bounds.top+height-1);
-        LineTo(hdcDraw, bounds.left, bounds.top+height-1);
-        LineTo(hdcDraw, bounds.left, bounds.top);
+            SelectObject(hdcDraw, GetStockObject(BLACK_BRUSH));
+
+            MoveToEx(hdcDraw, bounds.left, bounds.top, NULL);
+            LineTo(hdcDraw, bounds.left+width-1, bounds.top);
+            LineTo(hdcDraw, bounds.left+width-1, bounds.top+height-1);
+            LineTo(hdcDraw, bounds.left, bounds.top+height-1);
+            LineTo(hdcDraw, bounds.left, bounds.top);
+        }
     }
 };
 
@@ -894,8 +923,7 @@ void VLCPlugin::onPaint(HDC hdc, const RECT &bounds, const RECT &clipRect)
 {
     if( isVisible() )
     {
-        /** if VLC is playing, it may not display any VIDEO content 
-        ** hence, draw control logo*/
+        /* if VLC is in design mode, draw control logo */
         HDC hdcDraw = CreateCompatibleDC(hdc);
         if( NULL != hdcDraw )
         {