Explore the community Forums Lectora Lectora Questions & Answers Custom player breaks video

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #378800 Score: 0
    Profile photo of Jason Dalrymple
    Jason Dalrymple
    Member
    beginner
    intermediate
    profile
    wise owl
    curious george
    contributor
    friend finder
    31 pts
    @JasonADal

    I’ve created a custom audio player that I’m using throughout my course. There are a couple of pages that have a video and a setting from the CSS for the player is affecting the default video player, even if I have the controller set to none.

    I tracked down the issue to a piece of the custom audio CSS:

    div[id^”mep”] {
    width: 512px !important;
    }

    Is there a way to target that so that it ONLY applies to the audio player? Or, a way that I can attach an attribute to the video force it to the right width? (I’ll be doing some trial and error tomorrow, but thought I’d post asking as well).

    #378807 Score: 0
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    profile
    169 pts
    @Klaatu

    Sure. That’s a “begins with” selector (^). If you know the actual HTML ID, replace everything within the brackets[] with #xyz (whatever the html name is). The hash, or if you’re old like me a number sign, denotes what follows is an ID. So it would be like div#mep_01

    D

    #378884 Score: 0
    Profile photo of Jason Dalrymple
    Jason Dalrymple
    Member
    beginner
    intermediate
    profile
    wise owl
    curious george
    contributor
    friend finder
    31 pts
    @JasonADal

    I had often wondered, but never took the time to research, what the purpose of the (^) was. This could be exceedingly helpful going forward as I think about things.

    Instead of the HTML name, I replaced “mep” with “audio” so only applies to div’s that begin with “audio”. This worked AND didn’t affect other pages with different players. Yay!

    For the next trick, though, when I have my custom captions button (I disabled the player version, since it breaks tab use), if the audio is below the video, it breaks. This is because the div is based on the order (video = mep_0, audio = mep_1).

    My question is – Can I dynamically target the “mep” just for audio? Here’s the JS I’m using (from a previous thread):

    if(document.getElementById(“mep_0_captions_none”).checked){
    document.getElementById(“.mep_0_captions_none”).click();
    } else {
    document.getElementById(“mep_0_captions_none”).click();
    };

    I tried changing “0” to “1” and it didn’t seem to work. Is it possible to use the selector in the JS?

    #378899 Score: 0
    Profile photo of Jason Dalrymple
    Jason Dalrymple
    Member
    beginner
    intermediate
    profile
    wise owl
    curious george
    contributor
    friend finder
    31 pts
    @JasonADal

    Edit: I retested and changing 0 to 1 in the above code does work. From an ROI perspective, it may just be easier to do that in the few places where I have multiple media files, which, thankfully, is pretty rare.

    If there are other ideas, I totally welcome them!

    #378943 Score: 0
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    profile
    169 pts
    @Klaatu

    Are you trying to use your custom button to trigger the mejs button? Can you provide the file for me/us to tinker with?

    You should be able to look up the Dom tree and find something with audio in it the you can add to what you have. You might need an Nth child selector. I sense a bit of interest, check out jQuery Selectors. In another thread you asked about jQuery vs. Vanilla JS when used in Lectora (I added the last bit), well, this is one of the main reasons why. Look at all those awesome selectors that you can use to pin down your target. Doing those with vanilla JS is possible, some require a lot of code but.. why reinvent the wheel?

    #378966 Score: 0
    Profile photo of Tim K
    Tim K
    Member
    contributor
    beginner
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    wise owl
    curious george
    Group Member
    218 pts
    @timk

    … and remember what we did to the dropdown menus in the other thread. First get all the audio divs, then find the inputs inside them.

    Hint: While “^=” is a “begins with” selector, “$=” means “ends with”, which may be useful.

    #378975 Score: 0
    Profile photo of Jason Dalrymple
    Jason Dalrymple
    Member
    beginner
    intermediate
    profile
    wise owl
    curious george
    contributor
    friend finder
    31 pts
    @JasonADal

    Here’s a quick sample that reflects what I’m doing on this one – The CC is a custom button to work around the bug in the default player that breaks tab functioning at the CC button discussed in the thread Clickable media element

    In the end, changing the mep ending value may be the best option, since I rarely have more than one media file. I thought it might be a value to others I’ve seen that have multiple media elements on pages, especially as we’re thinking more and more about accessibility and the need for captions on audio.

    Tim – are you referring to the thread re: populating a droplist from an array or the one where we used a variable to determine the text of the “nth” option of the list?

    Is there a way to do “contains” as the div ID? If that’s the case, I can use the name of the player, which is the most common denominator in the div (div id = mep_X” class “mejs-container dhsplayer-small-no-cc”

    #379122 Score: 0
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    profile
    169 pts
    @Klaatu

    Thanks for posting the sample, Jason. I probably wont be able to look at it until this weekend (I hope) as things are getting crazy busy this time of year, as you might imagine. Question. Do you do anything with the audio and video other  than play? If you don’t need to use sync events you should consider adding in your own mediaElement.js player to avoid lectora code. You’d be really surprised how simple the actual mediaElement is to both implement and customize.

    #379125 Score: 0
    Profile photo of Jason Dalrymple
    Jason Dalrymple
    Member
    beginner
    intermediate
    profile
    wise owl
    curious george
    contributor
    friend finder
    31 pts
    @JasonADal

    The audio doesn’t have any events synced, but does play or start captions based on some user choices at the beginning of the course (auto play audio, captions only or captions and audio). The video DOES have events synced and in my course, is controlled by buttons that use JavaScript to go to a specific point in the video, where there is a pause event.

    I actually have a template that I’m looking at to see how I might be able to use the original mediaelement.js so down the road, I can alleviate the need for the separate captions button.

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.