[SOLVED] wxWidgets - wxMediaCtrl, how to loop media.
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Can someone please explain how looping a media works with wxMediaCtrl. I am fairly new wxWidgets and C++ in general, but not a complete beginner at this point, I'm making a application for browsing and managing audio samples, so far with wxMediaCtrl I'm able to load, play and stop media at will, by simply calling MediaCtrl->Load() or MediaCtrl->Play(), but I can't understand how to loop a media after it finishes playing, reading the documentation and the provided sample from wxWidgets, which is far too long, I do understand that I need to catch wxEVT_MEDIA_FINISHED, and make a function that does when this event is fired. But I can't get it to work. I have a function to play media when a button is pressed like,
Where SampleListView is a wxDataViewListCtrl, and db is SQLite3 database from where I'm grabbing the path to the file to load media in, and I have binded all event like,
This works, and I have similar function when a user click on SampleListView row it plays depending on the row number and filename, and I have a toggle button for loop that by it self just toggles a bool Looping to true or false, depending on the state of the button,
Can someone please explain how looping a media works with wxMediaCtrl. I am fairly new wxWidgets and C++ in general, but not a complete beginner at this point, I'm making a application for browsing and managing audio samples, so far with wxMediaCtrl I'm able to load, play and stop media at will, by simply calling MediaCtrl->Load() or MediaCtrl->Play(), but I can't understand how to loop a media after it finishes playing, reading the documentation and the provided sample from wxWidgets, which is far too long, I do understand that I need to catch wxEVT_MEDIA_FINISHED, and make a function that does when this event is fired. But I can't get it to work. I have a function to play media when a button is pressed like,
Where SampleListView is a wxDataViewListCtrl, and db is SQLite3 database from where I'm grabbing the path to the file to load media in, and I have binded all event like,
This works, and I have similar function when a user click on SampleListView row it plays depending on the row number and filename, and I have a toggle button for loop that by it self just toggles a bool Looping to true or false, depending on the state of the button,
and the function that deals with wxEVT_MEDIA_FINISHED is,
Code:
void Browser::OnMediaFinished(wxMediaEvent& event)
{
if (Looping)
{
if ( !MediaCtrl->Play() )
{
wxLogDebug("Could not loop");
MediaCtrl->Load(db.GetSamplePathByFilename(SampleListView->GetTextValue(SampleListView->GetSelectedRow(), 1).ToStdString()));
MediaCtrl->Play();
}
}
}
I cannot get it work or able to understand how to do it, if someone can maybe write a short example for looping media that would be great help.
Okay, I was able to fix it, it works now. All of this code above is correct its just I had wrong control ID in the Bind(), I put the ID of Loop button rather than MediaCtrl it self.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.