Пример #1
0
void OpenClip()
{
    HRESULT hr;

    // If no filename specified by command line, show file open dialog
    if(g_szFileName[0] == L'\0')
    {
        TCHAR szFilename[MAX_PATH];

        UpdateMainTitle();

        // If no filename was specified on the command line, then our video
        // window has not been created or made visible.  Make our main window
        // visible and bring to the front to allow file selection.
        InitPlayerWindow();
        ShowWindow(ghApp, SW_SHOWNORMAL);
        SetForegroundWindow(ghApp);

        if (! GetClipFileName(szFilename))
        {
            DWORD dwDlgErr = CommDlgExtendedError();

            // Don't show output if user cancelled the selection (no dlg error)
            if (dwDlgErr)
            {
                Msg(TEXT("GetClipFileName Failed! Error=0x%x\r\n"), GetLastError());
            }
            return;
        }

        // This sample does not support playback of ASX playlists.
        // Since this could be confusing to a user, display a warning
        // message if an ASX file was opened.
        if (_tcsstr((_tcslwr(szFilename)), TEXT(".asx")))
        {
            Msg(TEXT("ASX Playlists are not supported by this application.\n\n")
                TEXT("Please select a valid media file.\0"));
            return;
        }

        lstrcpy(g_szFileName, szFilename);
    }

    // Reset status variables
    g_psCurrent = Stopped;
    g_lVolume = VOLUME_FULL;
    
    // Start playing the media file
    hr = PlayMovieInWindow(g_szFileName, FALSE);

    // If we couldn't play the clip, clean up
    if (FAILED(hr) && ( hr != NS_E_LICENSE_REQUIRED ) )
        CloseClip();
}
Пример #2
0
void OpenClip()
{
    HRESULT hr;

    // If no filename specified by command line, show file open dialog
    if(g_szFileName[0] == L'\0')
    {
        TCHAR szFilename[MAX_PATH];

        UpdateMainTitle();

        InitPlayerWindow();
        SetForegroundWindow(ghApp);

        if (! GetClipFileName(szFilename))
        {
            DWORD dwDlgErr = CommDlgExtendedError();

            // Don't show output if user cancelled the selection (no dlg error)
            if (dwDlgErr)
            {
                Msg(TEXT("GetClipFileName Failed! Error=0x%x\r\n"), GetLastError());
            }
            return;
        }

        // This sample does not support playback of ASX playlists.
        // Since this could be confusing to a user, display a warning
        // message if an ASX file was opened.
        if (_tcsnicmp(szFilename, TEXT(".asx"), 4) == 0)
        {
            Msg(TEXT("ASX Playlists are not supported by this application.\n\n")
                TEXT("Please select a valid media file.\0"));
            return;
        }

        StringCchCopy(g_szFileName, NUMELMS(g_szFileName), szFilename);
    }

    // Reset status variables
    g_psCurrent = Stopped;
    g_lVolume = VOLUME_FULL;
    EnableWatermarkMenu(TRUE);

    // Start playing the media file
    hr = PlayMovieInWindow(g_szFileName);

    // If we couldn't play the clip, clean up
    if (FAILED(hr))
        CloseClip();
}
Пример #3
0
// Handler for (EC_)WMT_ACQUIRE_LICENSE
HRESULT HandleAcquireLicense(HRESULT hrStatus, WM_GET_LICENSE_DATA *pLicenseData)
{
    HRESULT hr = S_OK;

    if (NULL == pLicenseData)
    {
        return E_INVALIDARG;
    }
    
    // received notification that marks the end of license acquisition
    if (FAILED(hrStatus))
    {    
        //
        // NOTE:
        // We failed to acquire a license with silent acquisition.
        // Your application may want to try non-silent acquisition in this case.
        //

        // Windows XP can fail with a DRM license store error
        if (NS_E_DRM_LICENSE_STORE_ERROR == hrStatus)
        {
            Msg(TEXT("There was an error in the DRM license store! (hrStatus = 0x%x)\r\n"), hrStatus);
            return hr;
        }

        if (NS_E_DRM_LICENSE_NOTACQUIRED != hrStatus)
        {
            Msg(TEXT("Unable to acquire license! (hrStatus = 0x%x)\r\n"), hrStatus);
            return hr;
        }

        // make sure we have a challenge url
        if (NULL == pLicenseData->wszLocalFilename)
        {
            //DPF_ERR("HandleAcquireLicense: a null challenge url was passed");        
            return E_INVALIDARG;
        }
    }
    else
    {             
        // We successfully acquired the license, so reopen the file
        hr = PlayMovieInWindow(g_szFileName, TRUE);
        if (FAILED(hr))
        {
            Msg(TEXT("HandleAcquireLicense: Reader failed to open file! (hr = 0x%x)\r\n"), hr);
        }                    
    }

    return hr;
}
Пример #4
0
void OpenClip()
{
    HRESULT hr;

    // If no filename specified by command line, show file open dialog
    if(g_szFileName[0] == L'\0')
    {
        TCHAR szFilename[MAX_PATH];

        InitPlayerWindow();
        SetForegroundWindow(ghApp);

        if (! GetClipFileName(szFilename))
        {
            DWORD dwDlgErr = CommDlgExtendedError();

            // Don't show output if user cancelled the selection (no dlg error)
            if (dwDlgErr)
            {
                Msg(TEXT("GetClipFileName Failed! Error=0x%x\r\n"), GetLastError());
            }
            return;
        }

        // This sample does not support playback of ASX playlists.
        // Since this could be confusing to a user, display a warning
        // message if an ASX file was opened.
        if (_tcsstr((_tcslwr(szFilename)), TEXT(".asx")))
        {
            Msg(TEXT("ASX Playlists are not supported by this application.\n\n")
                TEXT("Please select a valid media file.\0"));
            return;
        }

        lstrcpyn(g_szFileName, szFilename, NUMELMS(g_szFileName));
    }

    EnableTickerMenu(TRUE);

    // Start playing the media file
    hr = PlayMovieInWindow(g_szFileName);

    // If we couldn't play the clip, clean up
    if (FAILED(hr))
        CloseClip();
}