Author Message

Posted: Wed Jun 12, 2013 12:59 pm   Post subject: Slide Advance via JS

Hi,

I am creating an app where I need to advance the slides externally using JavaScript. I can send the browser the request to execute a line of JS like:
Ih("n");
for perhaps advancing to the next slide when you press the 'n' key if we have set "n" in the 'customise control keys' section.

Thanks
Sean


Profile profile test

Posted: Wed Jun 12, 2013 3:25 pm   Post subject: Re: Slide Advance via JS

If you are talking about HTML5 presentations made with iSpring Pro 7 which doesn't have API, maybe imitating keystrokes is a wise solution. We haven't tested it though so you can give it a try. I found the discussion on the web regarding this thing and maybe you will find it useful:
http://stackoverflow.com/questions/1468 ... ith-jquery

If you are using Flash conversion you can use real methods from API to advance the presentation.


Profile profile test

Posted: Wed Jun 12, 2013 5:32 pm   Post subject: Re: Slide Advance via JS

Apologies for not being a bit more specific. The HTML5 has been created from iSpring Convertor 6.
Thanks for the JS link. I had already been aware of this code and tried to implement it. The problem comes that from this code

Code:
var press = jQuery.Event("keypress");
press.ctrlKey = false;
press.which = 40;
$("whatever").trigger(press);

The "whatever" bit is where I question what I am triggering. What should I reference. I've tried 'PlayerDemo', 'spr31_61325', 'player.js' and 'player' all with no result.
Any pointers helpful.

Thanks
Sean


Profile profile test

Posted: Wed Jun 12, 2013 6:40 pm   Post subject: Re: Slide Advance via JS

Thank you for clarifying the point. I must say that this is an extraordinary solution that didn't come on my mind anytime in the past. To be honest, it didn't come not only on my mind but on anybody's else:) It's great though!

I am not sure if it could work as we never tested anything like that. If we come up with any solution to make it work we will let you know in this forum thread.

Otherwise, the actual solution for it will be in HTML5 API when it's ready.


Profile profile test

Posted: Thu Jun 13, 2013 8:03 am   Post subject: Re: Slide Advance via JS

We have done a little research on it. Here is what we revealed:

First, iSpring player listens to document events so you might be using:

Code:
$(document).trigger(press);
instead of
Code:
$("whatever").trigger(press);

Second, jQuery samples, imitating keystrokes, are applicable for solutions that use this library and we don't.

Here is non-jQuery example so you can check it out:
http://stackoverflow.com/questions/5964 ... 2#12187302

Maybe it will work.


Profile profile test

Posted: Sun Jul 07, 2013 8:24 pm   Post subject: Re: Slide Advance via JS

Hi Mikhail,

I am now overwriting the end of the html with (straight after the PlayerDemo.load() section):

Code:
;
function simulateKeyEvent(character) {
  var evtDown = document.createEvent("KeyboardEvent");
  evtDown.initKeyboardEvent("keydown", true, true, window,
                    0, 0, 0, 0,
                    0, character.charCodeAt(0));
  var evtPress = document.createEvent("KeyboardEvent");
  evtPress.initKeyboardEvent("keypress", true, true, window,
                    0, 0, 0, 0,
                    0, character.charCodeAt(0));
  var evtUp = document.createEvent("KeyboardEvent");
  evtUp.initKeyboardEvent("keyup", true, true, window,
                    0, 0, 0, 0,
                    0, character.charCodeAt(0));
  document.dispatchEvent(evtDown);
  document.dispatchEvent(evtPress);
  document.dispatchEvent(evtUp);
                    //alert(character);
  var canceled = !document.dispatchEvent(evtDown);
  if(canceled) {
    // A handler called preventDefault
    alert("canceled");
  } else {
    // None of the handlers called preventDefault
    alert("not canceled");
  }
}
</script></body></html>

When I call the function I get the alert "Not canceled" back but it has not advanced the slide. I've tried submitting it to the document and window with any of the types of key up/down/press events as well as mouse clicks but no response. The document just doesn't seem to be getting the message. Any clues?

Thanks
Sean


Profile profile test

Posted: Wed Jul 10, 2013 9:06 am   Post subject: Re: Slide Advance via JS

Any help on this. I have a presentation in 2 days that could do with some assistance.
Thanks


Profile profile test

Posted: Fri Jul 12, 2013 12:43 pm   Post subject: Re: Slide Advance via JS

I am sorry to tell you but code review generally is not a free option as it requires developer's help which could also take significant time in tasks schedule. You can contact us at support email or submit a case so we could test our your code on our computers and figure out what's wrong there.


Profile profile test

Posted: Fri Jul 12, 2013 1:24 pm   Post subject: Re: Slide Advance via JS

Is it a no win no fee scenario or do I pay you money for you to tell me that it won't work? And how much? Which support plan do I need for this kind of solution?
Thanks
Pi Digital


Profile profile test

Posted: Fri Jul 12, 2013 2:42 pm   Post subject: Re: Slide Advance via JS

I am sorry as my reply regarding code review could seem too strict and negative but at the moment we cannot answer to this question because all developers are occupied with the upcoming release.

I also mentioned that code review is usually offered on a paid base even when we could take a developer from routine. It could be covered up with case analysis.

I am very glad to know that you are trying to implement a nice workaround for catching keystrokes and I appreciate it a lot but we cannot find a quick and relevant answer to your question at this time. Thank you for your understanding.


Profile profile test

Posted: Thu Jul 18, 2013 12:22 pm   Post subject: Re: Slide Advance via JS

We have done some tests on it. This code was working fine in Firefox but somehow not in IE.

Code:
function simulateKeyEvent(character) {
   var evtDown = document.createEvent("KeyboardEvent");
  evtDown.initKeyEvent("keydown", true, true, window,
                    0, 0, 0, 0,
                    character.charCodeAt(0), 0);

   document.dispatchEvent(evtDown);

}


Profile profile test

Posted: Thu Jul 18, 2013 1:09 pm   Post subject: Re: Slide Advance via JS

Excellent. That may well provide some clues. I'll have a play later and see what I get.
Thanks


Profile profile test
Display posts from previous:  Sort by  

  


Who is online
Who is online In total there are 4 users online :: 1 registered, 0 hidden and 3 guests (based on users active over the past 5 minutes)
Most users ever online was 108 on Thu Nov 21, 2013 3:41 pm

Registered users: Alexa [Bot]