Page 1 of 1

wx support to some feature

Posted: Wed Aug 29, 2018 7:49 pm
by wxProgrammer
Hello guys,
It's been a long time that I don't use wxWidgets and now I need to know if it supports some feature with the last stable version.
I need to make interactive videos based on a config file so I need:
1) parse a JSON file
2) play a video at full screen without showing media controls (play, pause, stop and so on)
3) perform some action when a video in on a specific second/interval of time
4) get input from a joypad

1) I found this plugin but IDK if it is good or if I need some other library that is not wx-based.
http://luccat.users.sourceforge.net/wxj ... nload.html

2) is it possible to run video directly without a visibile wxWindow? a simply process in background that run several video and some wxDialog without parent for asking questions to user (and play a video after the response)

3) I though to make a thread that cyclically (every 100ms) check the current position of the video and if it is in a specific range, it performs some specifc action

4) does wx support joypads C++ or I need some external library?

Thanks in advance

Re: wx support to some feature

Posted: Wed Aug 29, 2018 8:59 pm
by doublemax
1) parse a JSON file
I tried wxJSON, but found it too bloated. I personally use this one: https://github.com/nbsdx/SimpleJSON (just one header file)
2) play a video at full screen without showing media controls (play, pause, stop and so on)
Should be possible with wxMediaCtrl. Another alternative is https://github.com/tomay3000/wxVLC
3) perform some action when a video in on a specific second/interval of time
There is no event for that, but as you already suggested yourself, you could poll the current position. But don't use a thread, use a wxTimer.
4) get input from a joypad
http://docs.wxwidgets.org/trunk/classwx_joystick.html

Re: wx support to some feature

Posted: Thu Aug 30, 2018 8:21 am
by wxProgrammer
Thanks, very kind as always!
Just a question: some controller can vibrate. For example the PlayStation Dualshock controller. They have a 7V pin that allows it to vibrate. What about this with wx?

Re: wx support to some feature

Posted: Thu Aug 30, 2018 8:33 am
by doublemax
They have a 7V pin that allows it to vibrate. What about this with wx?
No. You'll need another component for this. But i can't recommend one, i've never used this. But if this is for Windows only, there should be plenty of sample code out there.

Re: wx support to some feature

Posted: Thu Aug 30, 2018 5:51 pm
by wxProgrammer
NP, thanks for all.

Re: wx support to some feature

Posted: Sat Jun 20, 2020 10:33 am
by tomay3000
Better come late than never.
wxProgrammer wrote:
Wed Aug 29, 2018 7:49 pm
3) perform some action when a video in on a specific second/interval of time
This is possible using wxVLC:
The static function:

Code: Select all

void OnPositionChanged_VLC(const libvlc_event_t *event, void *data)
{
    wxVLCFrame *mainFrame = ((wxVLCFrame *)wxGetApp().GetTopWindow());
    mainFrame->CallAfter(&wxVLCFrame::OnPositionChanged);
}
is defined and implemented just for that.
And the vlc event binding to it, is called in wxVLCFrame's constructor:

Code: Select all

libvlc_event_attach(vlc_evt_man, libvlc_MediaPlayerPositionChanged, ::OnPositionChanged_VLC, NULL);
So all you have to do is: Do an if test in this function:

Code: Select all

void wxVLCFrame::OnPositionChanged()
{
    libvlc_time_t currTime = libvlc_media_player_get_time(media_player);
    CurrTime_SttcTxt->SetLabel(wxTimeSpan::Milliseconds(currTime).Format());
    libvlc_time_t movieLength = libvlc_media_player_get_length(media_player);
    Timeline_Sldr->SetMax(movieLength / 1000);
    Timeline_Sldr->SetValue(currTime / 1000);
    MovieLength_SttcTxt->SetLabel(wxTimeSpan::Milliseconds(movieLength).Format());

    unsigned width = 0, height = 0;
    libvlc_video_get_size(media_player, 0, &width, &height);
    int video_track = libvlc_video_get_track(media_player);
    int audio_track = libvlc_audio_get_track(media_player);
    int subtitle = libvlc_video_get_spu(media_player);
    StatusBar1->SetStatusText(wxString::Format(_T("Video size: %d x %d     -     Video track: %d     -     Audio track: %d     -     Subtitle: %d"),
                              width, height, video_track, audio_track, subtitle));

    if (currTime >= deltaTimeMin && currTime <= deltaTimeMax) // (deltaTimeMin <-> deltaTimeMax) is your delta time interval.
    {
        // Do what ever you want to do here.
    }

    BoxSizer3->Layout();
}
wxProgrammer wrote:
Wed Aug 29, 2018 7:49 pm
2) play a video at full screen without showing media controls (play, pause, stop and so on)
There is another cross-platform alternative (which back-end, I consider better than vlc in terms of performance and is compiled all-in-one rather than using modules like vlc):
https://github.com/mpv-player/mpv-examp ... /wxwidgets
https://github.com/mpv-player/mpv-examp ... ets_opengl