mardi 27 août 2019

How do I set the time line for multiple instances?

I am working on creating a single dialog multi window video playback application using libvlc.I have taken help from https://www.codeproject.com/Articles/38952/VLCWrapper-A-Little-C-wrapper-Around-libvlc. I have made some progress in terms of the playing multiple videos at the same time.The video information is stored in a text file having name,starttime,endtime structure.The timeline can differ for each media. I have created an array of vlc instance pointers and storing media information in that. What I need to do now is to have a slider control which runs from min/max time and plays media from file when the position is equal to the time in the file.I am able to do that. The problem I am facing is in setting the correct position,synchronization and slider events. Here is what I have tried till now..

void SetControlsPosition()
{
    m_nTimer++;
    m_nMinusTimer--;
    if(m_nMinusTimer == m_nMediaTimeDiff)//m_nMediaTimediff is diff of file time
    {
        CString sMedia = get<2>(MediaVector[DiffIndex]);
        PMediaInstArr[DiffIndex]->SetScreenResource(pStaticArr[DiffIndex].GetSafeHwnd());
        PMediaInstArr[DiffIndex]->AttachEventController(EventControl,this);
        PMediaInstArr[DiffIndex]->InitializeAndOpenMedia(sMedia);
        PMediaInstArr[DiffIndex]->StartPlaying();
        if((MediaVector.Size()-1)>DiffIndex))
        {
            m_nMediaTimeDiff = get<0>(MediaVector[DiffIndex])-get<0> 
           (MediaVector[DiffIndex+1]);
        }
        m_nMinusTimer = 0;
        DiffIndex+=1;
    }
//Media1 start time = 11:30:15 Media2 start time = 11:30:30 then m_nMediaTimeDiff = 15
//MediaVector has the contents of media information and is a vector of tuples
//pStaticArr  is static control array created at runtime
//DiffIndex index for the time diff calculation
//Now setting the slider control
    if(PMediaInstArr.GetSize()>0)
    {
        nMediaLen =  PMediaInstArr[0]->GetMediaLength();//returns media len in millisec
        long newpos =  PMediaInstArr[0]->GetTime();//current time in millis
        CTimeSpan len(static_cast<time_t>(nMediaLen /1000);
        CTimeSpan actualPos(static_cast<time_t>(newpos /1000);
        CTimeSpan newTime = StartTimeStamp+actualPos;
        CTimeSpan TimeInterval= EndTimeStamp - StartTimeStamp;
        int nNewPosForSlider = nMediaLen ?static_cast<int>((static_cast<double> 
       (newpos)/static_cast<double>(nMediaLen)*100)):0;
        m_Slider.SetPos(nNewPosForSlider );
    }

Now this works as intended for a single media which I play separately. My question is how can I make it work for more than one media. I want to make it like a video debriefing kind of application.How do I handle HScroll events for slider for multiple medias.

Thanks.

Aucun commentaire:

Enregistrer un commentaire