wx support to some feature

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
wxProgrammer
Experienced Solver
Experienced Solver
Posts: 96
Joined: Thu Apr 17, 2014 10:10 am

wx support to some feature

Post 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
I'm Italian but we can speak C++ :)
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wx support to some feature

Post 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
Use the source, Luke!
wxProgrammer
Experienced Solver
Experienced Solver
Posts: 96
Joined: Thu Apr 17, 2014 10:10 am

Re: wx support to some feature

Post 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?
I'm Italian but we can speak C++ :)
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wx support to some feature

Post 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.
Use the source, Luke!
wxProgrammer
Experienced Solver
Experienced Solver
Posts: 96
Joined: Thu Apr 17, 2014 10:10 am

Re: wx support to some feature

Post by wxProgrammer »

NP, thanks for all.
I'm Italian but we can speak C++ :)
tomay3000
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Mon Apr 24, 2017 4:23 am

Re: wx support to some feature

Post 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
newbierajk
In need of some credit
In need of some credit
Posts: 7
Joined: Mon Aug 28, 2023 1:07 am

Re: wx wiget video player

Post by newbierajk »

Hi Tomay3000,

this is rajk and I am looking to build a vide player using wxwidget. I came across your media player already built on wxwidget using wxVLC 5 years back I got the code from Github. I am trying to build it and play with it?. Can you help me build it using MSVS 2022. Any help would be appreciated

regards,
rajk.
Post Reply