Explore the community Forums Lectora Lectora Questions & Answers Events in Audio/Video files again

Viewing 15 posts - 1 through 15 (of 37 total)
  • Author
    Posts
  • #316450 Score: 0
    Profile photo of Andrew Lian
    Andrew Lian
    Member
    beginner
    intermediate
    friend finder
    advanced
    contributor
    wise owl
    curious george
    profile
    12 pts
    @mlapl1

    I know it is possible to start playing an audio file and then setting an event which will trigger a stop action (so as to stop the playback). This means that I can play from the beginning of the file until a specific point in the file. I have already done this and it works fine.

    My question is as follows. Can I start playing from a specific Events point that is NOT the beginning of the file and then stop at a second Events point? My suspicion is that this can probably not happen as the player is not set up for random access but, rather, encounters instructions in the form of events *as it plays*. I hope someone can tell me that I am wrong… 🙁

    cheers and thanks

    andrew

    #316464 Score: 3
    Profile photo of Sergey Snegirev
    Sergey Snegirev
    Member
    contributor
    intermediate
    advanced
    friend finder
    lab member
    junior moderator
    advocate
    LUC16
    LUC16 Attendee
    wise owl
    336 pts
    @ssneg

    Normal Lectora actions are Play, Pause, Stop and Toggle Play/Pause. So you cannot jump to a random place in a file. If you could jump to a random place in a file, your Event 2 would just need to be set to “Pause”. Okay, let’s build a “jump to a random place” function 🙂

    In Lectora 16.1.x with the new awesome MediaElement player, it is as easy as running one line of code in a Run Javascript action: “mejs.players.mep_0.setCurrentTime(20)”. If you have more than one media player on the page, you might need to change mep_0 to mep_1, mep_2 and so on. And “20” is the time on the playhead in seconds. You can also enter decimals e.g. “20.4”

    Here’s a feature request (ping @support) – “Jump to a point in time” action for audio/video elements.

    This post has received 3 votes up.
    #316465 Score: 0
    Profile photo of Sergey Snegirev
    Sergey Snegirev
    Member
    contributor
    intermediate
    advanced
    friend finder
    lab member
    junior moderator
    advocate
    LUC16
    LUC16 Attendee
    wise owl
    336 pts
    @ssneg

    Also, if you share the actual purpose of what you are trying to build, it’d be easier to suggest an efficient way of building this 😉

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

    Sort of on the lines of what Sergey suggest above but a little different (both should work ).

    var myplayer =$(‘#audio48Media’)[“0”]; // Replace audio48Media with your elements HTML Name
    myplayer.setCurrentTime(64); // Starting Point
    myplayer.play(); // Start the audio

    $(‘#audio48Media’)[“0”].addEventListener(‘timeupdate’, function(e) { // Add event Listener so you can track current time
    var currentTime = myplayer.currentTime;
    if(currentTime >=78){ // This is the stop time
    myplayer.stop();
    }}, false);

    You only need one media player on the page and you can add as many buttons (or any other trigger) with as many start and stop times as you wish. Only one file to load and you can have all your talking points.

    Enjoy.

    This post has received 1 vote up.
    Attachments:
    1. Title-8.zip
    #316471 Score: 1
    Profile photo of Math Notermans
    Math Notermans
    Member
    contributor
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    LUC16 Attendee
    LUC16
    wise owl
    curious george
    119 pts
    @mnotermans5114

    As a sidenote to Darrel’s sample….    $(‘#    is a JQuery selector, so you do need JQuery too…

    This post has received 1 vote up.
    #316476 Score: 0
    Profile photo of Andrew Lian
    Andrew Lian
    Member
    beginner
    intermediate
    friend finder
    advanced
    contributor
    wise owl
    curious george
    profile
    12 pts
    @mlapl1

    Thank you all so much. It is getting very late here in Thailand. Will try and have a look tomorrow morning. I am basically trying to construct (find actually) an audio/video player which will go from point A to point B without the need for a streaming server. The reason for this is to avoid creating a lot of small files (saving both time and space) and also to have the possibility of determining A and B programmatically. This is for use in language learning, specifically listening comprehension. I was able to do this fairly simple with early versions of Toolbook. I was even able to do it by sending control characters from a standard terminal to videodisc players and, would you believe it, random access cassette recorders (he said revealing that he is a dinosaur in years). Now, with “modern technology” it is more complicated… but of course things are way ahead in other areas…

    The Lectora 16 player may actually be able to do this inside a nice quick development environment.

    goodnight for now

     

    #316486 Score: 2
    Profile photo of Andrew Lian
    Andrew Lian
    Member
    beginner
    intermediate
    friend finder
    advanced
    contributor
    wise owl
    curious george
    profile
    12 pts
    @mlapl1

    OK… could not help myself. Brought down a slightly newer version of jquery and published Darrel’s solution. Worked just great. I will try Sergey’s solution when I get a chance.

    Many thanks to all three of you. You have made my evening (and probably my next few months too).

    gnight again

    This post has received 2 votes up.
    #316487 Score: 1
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    profile
    200 pts
    @Klaatu

    Thanks Math, I use it so often I forget to mention it. Here’s the code with no jQuery (actually a better solution unless you need it for other stuff – less bloat).

    var myplayer = document.getElementById(“audio48Media”);
    myplayer.player.setCurrentTime(64);
    myplayer.play();

    myplayer.addEventListener(‘timeupdate’, function(e) {
    var currentTime = myplayer.currentTime;
    console.log(currentTime);
    if(currentTime >=78){
    myplayer.stop();
    }
    }, false);

    ‘Nite Andrew.

    This post has received 1 vote up.
    #316491 Score: 0
    Profile photo of Andrew Lian
    Andrew Lian
    Member
    beginner
    intermediate
    friend finder
    advanced
    contributor
    wise owl
    curious george
    profile
    12 pts
    @mlapl1

    Good Morning/Evening everyone,

    I have a question for Darrel. Why are there sync points in the audio file? I don’t see what they are supposed to do (except maybe deal with a potential OnDonePlaying problem).

    Cheers

    Andrew

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

    Good question. They have no meaning and I left them there accidentally. I initially added them because I wanted to see what would happen if I used JavaScript to select the start point of the audio and a Lectora sync point to try to stop it but it didn’t work. I would up having to to use the timeupdate MediaElement method which works wonderfully. I guess the forgotten sync points also answer your other post (happy accident). I seem to have no issues saving sync points. Well Andrew, it’s evening for me so this will be my final post for now. I’d like to hear how you make out using this. I think it’s a great idea to have one audio file and pull from it what you need. You should be able to pull off something similar to what you used to do in ToolBook (I still kinda miss it).

    #316493 Score: 0
    Profile photo of Andrew Lian
    Andrew Lian
    Member
    beginner
    intermediate
    friend finder
    advanced
    contributor
    wise owl
    curious george
    profile
    12 pts
    @mlapl1

    AND it works with video too (mp4 at least).

    There is a small problem (that I can live with) but thought I would ask anyway: the starting point for the clip seems to be found quite accurately (so far) but the ending point sometimes “slides” a bit. i.e. it stops a bit beyond the point requested (very occasionally a bit before) – and it is also a bit inconsistent – sometimes it it ok, sometimes not for no apparent reason. Maybe it has to do with the way that

    “myplayer.addEventListener(‘timeupdate’, function(e)”

    updates the time and how these two lines work:

    if(currentTime >=32.33){
    myplayer.stop();

    So here is what I am wondering. Would I get better results with AVI and WAV files which are “rawer” in terms of data OR would it be possible to calculate position in terms of frame (frame boundaries) rather than time? Problem is that as soon as you compress the raw data, that information disappears and you are basically left only with time (at least that is what I understand). Is there some way that I can get “frame accuracy” or its equivalent (milliseconds would be good) as I work with languages and milliseconds do count. The other problem of course is that uncompressed files are huge.

    Any further thoughts? Thank you!

    #316535 Score: 0
    Profile photo of Trivantis Support
    Trivantis Support
    Moderator
    friend finder
    intermediate
    advanced
    contributor
    junior moderator
    Trivantis Support
    verified member
    profile
    wise owl
    curious george
    19 pts
    @Support

    The “jump to time” feature is in our list of enhancements for the media player. We have plans to keep updating and releasing new features for the HTML5 player as we move through the Fall. I made sure to tag the request with a link to this thread so that are developers are aware of the customer interest in this feature.

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

    Andrew, this can be rectified. I have been quite busy. I’ll take a look at it and get back to you. This has to do with the rate in which the timeupdate is fired.

    This post has received 1 vote up.
    #316539 Score: 0
    Profile photo of Andrew Lian
    Andrew Lian
    Member
    beginner
    intermediate
    friend finder
    advanced
    contributor
    wise owl
    curious george
    profile
    12 pts
    @mlapl1

    Thank you so much Darrel. Very useful to know. There is no hurry at all – so please do not go to any trouble over this – I am just so glad to see the player can do random access.

    Actually, I thought it had something to do with the OS or the sampling rate of files or… as this has been happening to me since Toolbook days and I basically thought it was probably impossible to fix.

    Thanks again,

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

    Make sure when you add the “Jump to Time” feature that it includes the ability to stop before the end.

    Thank you.

    Darrel

Viewing 15 posts - 1 through 15 (of 37 total)

You must be logged in to reply to this topic.