Click here to Skip to main content
15,881,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,
I have been facing a very strange problem in which the slider control placed below the embedded media player vanishes player vanishes sometimes when the video is loaded and played.
Language - vc++, mfc, visual studio 2013

Let me explain the software setup.

The software consists of a dialog panel with tabs in it. The two tabs importance are Analysis and Video tab.
The video tab has two embedded media player active X panels embedded in it. "no ui" mode is used for the payer
In the video tab are buttons "browse video" "Play video" "pause Video"
Below the video panel is a Slider control which moves as the video plays.
The analysis tab also has a media player active X panel embedded in it. "no ui" is used for the player
In the analysis tab are buttons "browse video" "Play video" "pause Video"
Below the video panel is a Slider control which moves as the video plays.

The sequence of operations which cause the problem are as below.

1. Go to the video tab load a video using "browse video"
2. Go to the analysis tab. (The video loaded in the video tab should automatically load and play. This works) The "slider control" shows fine and moved well.
3. Go back to the video tab and load another video using the "browse video"
4. Go to the analysis tab. (The newly loaded video should automatically load and play. This works fine)

Problem is the slider control sometimes vanishes after step 4.

It is also observed that if the task bar is moved to vertical position from horizontal, then the slider control reappears. This is the only way it reappears.

The slider control is there to show the position of the video playing. This is done by using a timer which wakes up every 100ms and get the position of the and based on it updates the slider position.
The slider is also used for scrubbing through the video.

Any help will be very much appreciated. If any more information of any kind is needed let me know.
Thanks and Regards,
Rakesh

What I have tried:

I have tried invalidation, redraw, SetWindowPos, movewindow, updatewindow, and many other things, changed the order of rendering between slider and media player.
Nothing has worked.
What worked was if I disable auto play I always get the slider control but the what is of interest is that it should load and play on it own without the slider vanishing.
Posted
Comments
Member 11380615 29-May-16 2:40am    
Given below is the ontimer function.

void CAnalyseDialog::OnTimer(UINT_PTR nIDEvent)
{
if (!IsWindowVisible())
{
//LOGSAMP.LOGRP(FS,"Window not visible");
//UpdateSliderOnPause();
if (AnalysisVideoPausedInOnTimer == 0)
{
m_spControls1->pause();
AnalysisVideoPausedInOnTimer = 1;
}
return;
}
else
{
AnalysisVideoPausedInOnTimer = 0;
}

SwitchVideoPlay();
//return;
if (nIDEvent == TimerId)
{
if (LeftPlayerState == 2)
{
if (mVideoTimer != NULL)
{
//LOGD.LOGRP(FL, "Killing Video Timer");
//KillTimer(nIDEvent);
}
}
else
{
int lminRange, lmaxRange;
double lnewPosTimer;
int newPosSlider;

if ((LeftPlayerState == 3) && (m_spControls1PauseCount == 0))
{
//sliderLeft.
//LOGD.LOGRP(FL, "Repositioning left slider");

m_spControls1->get_currentPosition(&getCurrentLeftPos);
LOGSAMP.LOGRP(FS, "Current left player pos = ", (int) getCurrentLeftPos);
sliderLeft.GetRange(lminRange, lmaxRange);
LOGSAMP.LOGRP(FS, "Slider min Range = ", lminRange);
LOGSAMP.LOGRP(FS, "Slider max Range = ", lmaxRange);

lnewPosTimer = (lmaxRange - lminRange)*getCurrentLeftPos / onlysecsLeft;
newPosSlider = lnewPosTimer + lminRange;
LOGSAMP.LOGRP(FS, "newPosSlider = ", newPosSlider);
repositioningLeftSliderTimer = 1;
if (newPosSlider > lmaxRange)
newPosSlider = lmaxRange;
if (newPosSlider < lminRange)
newPosSlider = lminRange;

if (DlgPtr->m_VideoDialog.newVideoCHosenInTabVideo==0)
sliderLeft.SetPos(newPosSlider);
//sliderLeft.EnableWindow(false);

//sliderLeft.EnableWindow(true);
}
}
//LOGD.LOGRP(FL, "In Video Timer");
}
}
//==============================================




///////////////////////////////////////////////////////////////////////////////////
Given below is the SwitchVideoPlay funciton
void CAnalyseDialog::SwitchVideoPlay()
{
if (DlgPtr->m_VideoDialog.newVideoCHosenInTabVideo == 2)
{
LOGSAMP.LOGRP(FS, "newVideoCHosenInTabVideo = ", newVideoCHosenInTabVideo);
if (scrLeftMaxOnce != 0)
{
//LOGSAMP.LOGRP(FS, "scrLeftMaxOnce = ", scrLeftMaxOnce);

//sliderLeft.MoveWindow(ActualVideoSizeLeft.left + 1, playerTop + ActualVideoSizeLeft.bottom + spacingBetPlayerScrub / 2 + ActualVideoSizeLeft.top, ActualVideoSizeLeft.right - 1, 40, true);
//sliderLeft.Invalidate();
//sliderLeft.RedrawWindow();
//Sleep(50);
//LOGSAMP.LOGRP(FS, "Slider Visibility 4 = ", sliderLeft.IsWindowVisible());

//HRESULT hrPause1 = m_spControls1->play();

//sliderLeft.SetWindowPos(NULL, ActualVideoSizeLeft.left + 1, playerTop + ActualVideoSizeLeft.top - 50, ActualVideoSizeLeft.right - 1, 40, SWP_SHOWWINDOW);
//sliderLeft.UpdateWindow();
// m_pMainWnd = pMainFrame;

//DlgPtr->m_AnalyseDialog.RedrawWindow(NULL, NULL, RDW_ERASE | RDW_INVALIDATE);
//sliderLeft.MoveWindow(ActualVideoSizeLeft.left + 1+1, playerTop + ActualVideoSizeLeft.bottom + spacingBetPlayerScrub / 2 + ActualVideoSizeLeft.top, ActualVideoSizeLeft.right - 1, 40, true);
//sliderLeft.ShowWindow(SW_SHOW);
//LOGSAMP.LOGRP(FS, "Slider Visibility 5 = ", sliderLeft.IsWindowVisible());

//sliderLeft.ShowWindow(SW_HIDE);
//sliderLeft.ShowWindow(SW_SHOW);

//Invalidate();
//LOGSAMP.LOGRP(FS, "Slider Visibility 6 = ", sliderLeft.IsWindowVisible());

}

DlgPtr->m_VideoDialog.newVideoCHosenInTabVideo = 0;
return;
}

if (DlgPtr->m_VideoDialog.newVideoCHosenInTabVideo == 3)
{
LOGSAMP.LOGRP(FS, "newVideoCHosenInTabVideo = ", newVideoCHosenInTabVideo);
if (scrLeftMaxOnce != 0)
{

HRESULT hrPause1 = m_spControls1->play();
}

DlgPtr->m_VideoDialog.newVideoCHosenInTabVideo = 0;
return;
}


if (IsWindowVisible())
{
if (DlgPtr->m_VideoDialog.newVideoCHosenInTabVideo == 1)
{
LOGSAMP.LOGRP(FS, "In Analyse Timer newVideoCHosenInTabVideo ==1");
if (currentAnalPLayingURL != DlgPtr->m_VideoDialog.VideoFilePlay1)
{
LOGSAMP.LOGRP(FS, "In Analyse Timer the two play strings dont match");
left
Member 11380615 29-May-16 2:42am    
//==============================================
void CAnalyseDialog::SwitchVideoPlay()
{
if (DlgPtr->m_VideoDialog.newVideoCHosenInTabVideo == 2)
{
LOGSAMP.LOGRP(FS, "newVideoCHosenInTabVideo = ", newVideoCHosenInTabVideo);
if (scrLeftMaxOnce != 0)
{
//LOGSAMP.LOGRP(FS, "scrLeftMaxOnce = ", scrLeftMaxOnce);

//sliderLeft.MoveWindow(ActualVideoSizeLeft.left + 1, playerTop + ActualVideoSizeLeft.bottom + spacingBetPlayerScrub / 2 + ActualVideoSizeLeft.top, ActualVideoSizeLeft.right - 1, 40, true);
//sliderLeft.Invalidate();
//sliderLeft.RedrawWindow();
//Sleep(50);
//LOGSAMP.LOGRP(FS, "Slider Visibility 4 = ", sliderLeft.IsWindowVisible());

//HRESULT hrPause1 = m_spControls1->play();

//sliderLeft.SetWindowPos(NULL, ActualVideoSizeLeft.left + 1, playerTop + ActualVideoSizeLeft.top - 50, ActualVideoSizeLeft.right - 1, 40, SWP_SHOWWINDOW);
//sliderLeft.UpdateWindow();
// m_pMainWnd = pMainFrame;

//DlgPtr->m_AnalyseDialog.RedrawWindow(NULL, NULL, RDW_ERASE | RDW_INVALIDATE);
//sliderLeft.MoveWindow(ActualVideoSizeLeft.left + 1+1, playerTop + ActualVideoSizeLeft.bottom + spacingBetPlayerScrub / 2 + ActualVideoSizeLeft.top, ActualVideoSizeLeft.right - 1, 40, true);
//sliderLeft.ShowWindow(SW_SHOW);
//LOGSAMP.LOGRP(FS, "Slider Visibility 5 = ", sliderLeft.IsWindowVisible());

//sliderLeft.ShowWindow(SW_HIDE);
//sliderLeft.ShowWindow(SW_SHOW);

//Invalidate();
//LOGSAMP.LOGRP(FS, "Slider Visibility 6 = ", sliderLeft.IsWindowVisible());

}

DlgPtr->m_VideoDialog.newVideoCHosenInTabVideo = 0;
return;
}

if (DlgPtr->m_VideoDialog.newVideoCHosenInTabVideo == 3)
{
LOGSAMP.LOGRP(FS, "newVideoCHosenInTabVideo = ", newVideoCHosenInTabVideo);
if (scrLeftMaxOnce != 0)
{

HRESULT hrPause1 = m_spControls1->play();
}

DlgPtr->m_VideoDialog.newVideoCHosenInTabVideo = 0;
return;
}


if (IsWindowVisible())
{
if (DlgPtr->m_VideoDialog.newVideoCHosenInTabVideo == 1)
{
LOGSAMP.LOGRP(FS, "In Analyse Timer newVideoCHosenInTabVideo ==1");
if (currentAnalPLayingURL != DlgPtr->m_VideoDialog.VideoFilePlay1)
{
LOGSAMP.LOGRP(FS, "In Analyse Timer the two play strings dont match");
leftVideoFps = DlgPtr->m_VideoDialog.leftVideoFps;
onlysecsLeft = DlgPtr->m_VideoDialog.onlysecsLeft;
leftVideoWidthInFile = DlgPtr->m_VideoDialog.leftVideoWidthInFile;
leftVideoHeightInFile = DlgPtr->m_VideoDialog.leftVideoHeightInFile;
totLeftVideoFrames = leftVideoFps*onlysecsLeft;
LOGSAMP.LOGRP(FS, "left video fps = ", leftVideoFps);
LOGSAMP.LOGRP(FS, "tot left frames = ", totLeftVideoFrames);

VideoSizeInFile.top = 0;
VideoSizeInFile.left = 0;
VideoSizeInFile.right = leftVideoWidthInFile;
VideoSizeInFile.bottom = leftVideoHeightInFile;
CalculateNewVideoSize();
ActualVideoSizeLeft.top = 0;
ActualVideoSizeLeft.left = 0;
ActualVideoSizeLeft.right = ActualVideoSize.right;
ActualVideoSizeLeft.bottom = ActualVideoSize.bottom;

ActualPlayerLeft = PlayerWindow;

LONG VidLeftCentX;
LONG VidLeftCentY;
LONG PlayerWinCentX;
LONG PlayerWinCentY;

VidLeftCentX = ActualVideoSizeLeft.right / 2;
VidLeftCentY = ActualVideoSizeLeft.bottom / 2;

PlayerWinCentX = PlayerWindow.right / 2;
PlayerWinCentY = PlayerWindow.bottom / 2;

LOGSAMP.LOGRP(FS, "onlysecsLeft = ", onlysecsLeft);
LOGSAMP.LOGRP(FS, "left width = ", leftVideoWidthInFile);
LOGSAMP.LOGRP(FS, "left height = ", leftVideoHeightInFile);

scrLeftMaxOnce = 0;
firstFileLeftChosen = 1;

sliderLeft.SetPos(0);
sliderLeft.Invalidate();

//vidCtrl1.MoveWindow(ActualVideoSizeLeft.left, playerTop + ActualVideoSizeLeft.top, ActualVideoSizeLeft.right, ActualVideoSizeLeft.bottom, true);
//sliderLeft.MoveWindow(ActualVideoSizeLeft.left + 1, playerTop + ActualVideoSizeLeft.bottom + spacingBetPlayerScrub / 2 + ActualVideoSizeLeft.top, ActualVideoSizeLeft.right - 1, 40, true);

m_spControls1->stop();
//Slee
Member 11380615 29-May-16 2:43am    
////////////////////////////////////////////////////////////////////////////
void CAnalyseDialog::PlayStateChangeOcx3(long NewState)
{
//return;
// TODO: Add your message handler code here
LeftPlayerState = NewState;

LOGSAMP.LOGRP(FS, "Player State = ", (int)NewState);
LOGSAMP.LOGRP(FS, "scrLeftMaxOnce = ", (int)scrLeftMaxOnce);
LOGSAMP.LOGRP(FS, "totLeftVideoFrames = ", (int)totLeftVideoFrames);


if (NewState == 3)
{
if (mVideoTimer == NULL)
{
mVideoTimer = SetTimer(TimerId, TimerDuration, NULL);
}

if (scrLeftMaxOnce == 0)
{
sliderLeft.SetRange(0, totLeftVideoFrames, true);
//sliderLeft.MoveWindow(6, 49 + 30 + (cScreenXWidth / 2 - 12)*leftVideoHeightInFile / leftVideoWidthInFile +50, cScreenXWidth / 2 - 12, 40, true);
//m_pWMPPlayer1->put_uiMode(L"none");

//LOGSAMP.LOGRP(FS, "playerTop = ", playerTop);
//LOGSAMP.LOGRP(FS, "ActualVideoSizeLeft.left = ", ActualVideoSizeLeft.left);
//LOGSAMP.LOGRP(FS, "ActualVideoSizeLeft.left = ", ActualVideoSizeLeft.bottom);
//LOGSAMP.LOGRP(FS, "ActualVideoSizeLeft.left = ", ActualVideoSizeLeft.top);
//LOGSAMP.LOGRP(FS, "ActualVideoSizeLeft.left = ", ActualVideoSizeLeft.right);


vidCtrl1.MoveWindow(ActualVideoSizeLeft.left, playerTop + ActualVideoSizeLeft.top, ActualVideoSizeLeft.right, ActualVideoSizeLeft.bottom, true);
sliderLeft.MoveWindow(ActualVideoSizeLeft.left + 1, playerTop + ActualVideoSizeLeft.bottom + spacingBetPlayerScrub/2 + ActualVideoSizeLeft.top, ActualVideoSizeLeft.right - 1, 40, true);
//sliderLeft.ShowScrollBar(SB_HORZ, TRUE);
//sliderLeft.ShowCaret();
//vidCtrl1.UpdateWindow();
//LOGSAMP.LOGRP(FS,"Slider Visibility 0 = ",sliderLeft.IsWindowVisible());
HRESULT hrPause1 = m_spControls1->pause();
//HRESULT hrPause1 = m_spControls1->pause();
scrLeftMaxOnce = 1;
//LOGSAMP.LOGRP(FS, "Slider Visibility 1 = ", sliderLeft.IsWindowVisible());

Invalidate();
//LOGSAMP.LOGRP(FS, "Slider Visibility 2 = ", sliderLeft.IsWindowVisible());

RedrawWindow();
//LOGSAMP.LOGRP(FS, "Slider Visibility 3 = ", sliderLeft.IsWindowVisible());

}


//VARIANT_BOOL bSc = VARIANT_TRUE;
//HRESULT hrFull;
if (m_spControls1PauseCount == 1)
{
//HRESULT hrPause1 = m_spControls1->pause();
//m_spControls1->pause();
//m_spControls1PauseCount = 0;
//LOGD.LOGRP(FL, "In state changed 1 and m_spControls1PauseCount == 1");
}
//hrFull = m_pWMPPlayer1->put_fullScreen(bSc);
}

}
Member 11380615 29-May-16 3:02am    
While the slider control is not visible it is actually there and fully functional.
If I try to approximate its position (which is slightly below the player window) and try to scrub the video. The scrubbing happens fine.
George Jonsson 29-May-16 4:13am    
Don't post your code in the comment section. (No one is going to read it like this)
Use the Improve question button instead. And don't forget to format the code properly.
Also clearly indicate where in the code you think the problem is.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900