What could be reasons the stop command is not ever called?

  • 1
  • Question
  • Updated 3 years ago
  • Answered
  • (Edited)
The stop command never seems to be sent to my custom widget.
Photo of Eli Taylor

Eli Taylor

  • 340 Points 250 badge 2x thumb

Posted 3 years ago

  • 1
Photo of HSuarez

HSuarez

  • 11,896 Points 10k badge 2x thumb
Hi Eli,
If you wish you can share the code to the Community to have a look.  Thanks! 
Photo of Eli Taylor

Eli Taylor

  • 340 Points 250 badge 2x thumb
widgetId = prefs.getString("id"),
displayId = "test",
startTime = 0,
stopTime = 0;

gadgets.rpc.call("", "rsparam_get", null, widgetId, "displayId");
gadgets.rpc.register("rsparam_set_" + widgetId, getDisplayHandler);
gadgets.rpc.register("rscmd_play_" + widgetId, playHandler);
gadgets.rpc.register("rscmd_stop_" + widgetId, stopHandler);

function getDisplayHandler(name, value) {
    displayId = value;
}

function playHandler(){
    console.log("play event received");
}

function stopHandler(){
    console.log("stop event received");
}

// No Right-Clicky
window.oncontextmenu = function() {return false;};

$(document).ready(function() {
    // Doc is ready, so let's load our presentation into the iFrame.
    $("#myFrame").attr("src", 'http://viewer-test.appspot.com/Viewer.html?type=presentation&id='+presentationId+'&showui=false').attr("width", prefs.getInt("rsW")).attr("height", prefs.getInt("rsH"));
    // Turn off the loading spinner
    if (isLoading) {
	isLoading = false;
	readyEvent();
    }
});

function readyEvent() {	
    // Tell the player that we have our content loaded and to unhide the iFrame.
    gadgets.rpc.call("", "rsevent_ready", null, prefs.getString("id"), false, false, false, true, false);
    console.log("Ready");
}
(Edited)
Photo of Eli Taylor

Eli Taylor

  • 340 Points 250 badge 2x thumb
This is what I have right now.
Photo of William Oneal

William Oneal, Champion

  • 13,770 Points 10k badge 2x thumb
Use the pause command instead of the stop command. In the pause command use the done event.

gadgets.rpc.register("rscmd_pause_" + widgetId, pauseHandler);


The viewer will call pause instead of stop. :)
Photo of Eli Taylor

Eli Taylor

  • 340 Points 250 badge 2x thumb
Pause seems to be called right after play. I need something to be called at the end of the presentation playing.
Photo of William Oneal

William Oneal, Champion

  • 13,770 Points 10k badge 2x thumb
If the placeholder with the widget has a set duration then it will call pause fairly quickly. You will need to set the Play until done in the placeholder so that it won't call pause. If its doing it real quick even with that set then you have something wrong in your coding. 
Photo of Blake Freeman

Blake Freeman, Official Rep

  • 36,116 Points 20k badge 2x thumb
William,

Thanks for the input!

Eli, 

Please let us know your progress!
Photo of Eli Taylor

Eli Taylor

  • 340 Points 250 badge 2x thumb
It does seem to be working now with the pause command after setting the play until done setting. I had to add a new item with my widget because you cannot edit that setting on an existing item.