Thanks for your reply. I had in fact decided not to try to resize anything for YouTube videos a) because my code could not get videoWidth and videoHeight for YouTube videos and b) because it seems to me they always use the same ratio between width and height anyway. Also, as I said before, I am much more concerned about eliminating the
rs problem at the moment. I have now discovered that most of my timeouts were unnecessary but I have identified the one that
is necessary.
This bit of code comes after a vast amount of unrelated stuff that loads the exercise. I don't think the preceeding code has any relevance to the problem.
- Code: Select all
{ ...
//Load video
var isChrome = false; //TEMPORARY, I HAVE SOME CODE THAT DETECTS CHROME THAT WILL GO HERE
if (keys.isNet == true) // isNET MEANS THE SOURCE FILE ADDRESS HAS // IN IT I.E. IT IS A YOUTUBE VIDEO
{
fileName = sharedActions.myArray[3];
/*
if (isChrome == true) //THIS WORKS BUT WE DON'T NEED IT YET
{
var lastYT = tbfunction_readCookie("lastYT", "session");
if (lastYT == sharedActions.myArray[3])
{
isChrome = false; //The video can be started with the play button because it has already be used in this session.
}
}
***/
if (isChrome == true)
{
tbfunction_htmlVideoLoader("screen", "youtube", false, "", "", "", "", "", "", fileName);
//tbfunction_createCookie("lastYT", sharedActions.myArray[3], "", "session");
tbfunction_setOpacity("screen", 100);
tbfunction_pgTimer(true, 200, "loadChrome1") //SET A TIMER IN LOADCHROME1
}
else
{
tbfunction_htmlVideoLoader("screen", "youtube", "", "", "continuous", "", "", "", "", fileName);
tbfunction_setOpacity("screen", 1);
tbfunction_pgTimer(true, 200, "load2"); //SET A TIMER IN LOAD2
}
}
else
{
fileName = "../../" + sharedActions.myArray[1] + "/" + sharedActions.myArray[4] + "/teachers/" + sharedActions.myArray[6] + "/" + sharedActions.myArray[5] + "/" + sharedActions.myArray[2] + "/" + sharedActions.myArray[3];
tbfunction_htmlVideoLoader("screen", false, true, "", "continuous", "", "", "", "", fileName) //WHY DOES AUTOPLAY HAVE TO BE TRUE TO START THE VIDEO AND GET SOUND??
tbfunction_setOpacity("screen", 1);
tbfunction_pgTimer(true, 200, "load2")
}
} //If there is no server error.
So a timer is set either in
load2 or
loadChrome1 load2 allows me to determine the length of the video when an exercise is being made but in this case it is just used to signal that the video is loaded and that the user can use a play button to start it.
loadChrome1 works in a similar fashion but allows the user to click on the all important YouTube button (if Chrome is being used) and starts a timer in
loadChrome2 which stops the video, unloads it and reloads it using the
continuous parameter (which I need for my position pointer system). The user can now use my play button because the 'official' button has lifted the security restriction. No problem if playBetween is not used but if it is
this.rs shows up immediately. Here is the code for
load2,
loadChrome1 and
loadChrome2 LOAD2
- Code: Select all
<load2>
<function name="myUser" event="user" params="evt,value" useTB="true">
<![CDATA[
var result = tbfunction_htmlVideoControl("screen", "duration"); // video metadata is available.
//tbfunction_pgTBObjSet("ML2", "text", result);
if (result > 0)
{
tbfunction_pgTimer("", "", "load2", true); //stop timer
var fct = function() //VERY IMPORTANT WITHOUT THIS WE GET RS IS UNDEFINED
{
if (keys.totalLength == 0 || keys.new == true)
{
keys.totalLength = resultB * 1;
keys.endPos = keys.TotalLength;
//startPos = 0 by default;
keys.unit = keys.totalLength / 667;
keys.unit = Math.round(keys.unit);
}
sharedActions.getUnit10(keys.unit);
sharedActions.showFractions(keys.totalLength);
tbfunction_pgTBObjSet("pleaseWait", "visible", false);
tbfunction_pgTBObjSet("gif", "visible", false);
tbfunction_pgTBObjSet("cover", "visible", false);
tbfunction_pgTBObjSet("shield", "visible", false);
tbfunction_pgStyleObject("shield", "cursor", "default");
tbfunction_htmlVideoControl("screen", "volume", 0);
if (keys.isNet == true)
{
tbfunction_pgTBObjSet("videoScreen", "size", "548,322");
tbfunction_pgTBObjSet("videoScreen", "top", 93);
tbfunction_createAlphaShadow("screenShadow", false);
}
else
{
//sharedActions.setScreenSize();
tbfunction_createAlphaShadow("screenShadow", false);
}
tbfunction_snapObjectToCenter("isLoaded", "screen");
tbfunction_pgTBObjSet("isLoaded", "visible", true);
if (keys.new == true)
{
//keys.nextAction = 4;
sharedActions.showRequest("394`1", "1") //Do you want to change the length of the media clip. You can redefine the beginning and/or the end BEFORE you create your exercise. Yes, No
}
}
setTimeout(fct, 200);
}
]]>
</function>
</load2>
LOADCHROME1
- Code: Select all
<loadChrome1>
<function name="myUser" event="user" params="evt,value" useTB="true">
<![CDATA[
var result = tbfunction_htmlVideoControl("screen", "duration"); // video metadata is available.
if (result > 0)
{
tbfunction_pgTimer("", "", "loadChrome1", true);
var fct = function()
{
tbfunction_pgTBObjSet("noEntry", "height", 100);
tbfunction_pgTBObjSet("noEntry", "top", 295);
var txt = sharedActions.splitter("238`2");
tbfunction_pgTBObjSet("myTextBox", "text", txt); //To start the video for the first time, click the button above. Then you must use the button on the left.
var myWidth = tbfunction_pgTBObjGet("myTextBox", "width");
var myHeight = tbfunction_pgTBObjGet("myTextBox", "height");
tbfunction_pgTBObjSet("myShadow", "width", myWidth);
tbfunction_pgTBObjSet("myShadow", "height", myHeight);
tbfunction_createAlphaShadow("myShadow");
tbfunction_pgTBObjSet("infoGroup", "left", 200);
tbfunction_pgTBObjSet("infoGroup", "top", 367);
tbfunction_pgTBObjSet("play", "enabled", false);
tbfunction_pgTBObjSet("goStart", "enabled", false);
tbfunction_pgTBObjSet("pane", "visible", true);
tbfunction_pgTBObjSet("changepos", "left", 39);
tbfunction_pgTBObjSet("pleaseWait", "visible", false);
tbfunction_pgTBObjSet("gif", "visible", false);
tbfunction_pgTBObjSet("shield", "visible", false);
tbfunction_pgStyleObject("shield", "cursor", "default");
tbfunction_pgTBObjSet("AMarkers", "visible", true);
//I don't know why this is necessary!!
tbfunction_changeObjectLayer("AMarkers", "above", "pane");
tbfunction_changeObjectLayer("pane", "above", "AMarkers");
//AMarkers will resume their original layer in cover user below!!
tbfunction_pgTBObjSet("infoGroup", "visible", true);
tbfunction_pgTBObjSet("buttons", "enabled", false, "", true);
tbfunction_pgTBObjSet("moreButtons", "enabled", false, "", true);
tbfunction_pgTBObjSet("play", "enabled", false);
tbfunction_pgTBObjSet("goStart", "enabled", false);
tbfunction_setOpacity("screen", 100);
tbfunction_pgTimer(true, 200, "loadChrome2");
}
setTimeout(fct, 200);
}
]]>
</function>
</loadChrome1>
LOADCHROME2
- Code: Select all
<loadChrome2>
<function name="myUser" event="user" params="evt,value" useTB="true">
<![CDATA[
var timeCode = tbfunction_htmlVideoControl("screen", "currentTime");
//tbfunction_pgTBObjSet("ML1", "text", timeCode);
if (timeCode > 100)
{
tbfunction_pgTimer("", "", "loadChrome2", true);
var fct = function ()
{
tbfunction_htmlVideoControl("screen", "stop");
tbfunction_htmlVideoControl("screen", "unload");
tbfunction_setOpacity("screen", 1);
//YouTube video is reloaded.
tbfunction_htmlVideoLoader("screen", "youtube", false, "continuous", "", "", "", "", "", sharedActions.myArray[3]);
tbfunction_pgTBObjSet("infoGroup", "visible", false);
tbfunction_changeObjectLayer("AMarkers", "above", "coverMarkers");
tbfunction_pgTBObjSet("noEntry", "height", 438);
tbfunction_pgTBObjSet("play", "enabled", true);
tbfunction_pgTBObjSet("pane", "visible", false);
tbfunction_pgTBObjSet("cover", "visible", false);
tbfunction_pgTBObjSet("buttons", "enabled", true, "", true);
tbfunction_pgTBObjSet("moreButtons", "enabled", true, "", true);
tbfunction_pgTBObjSet("play", "enabled", true)
sharedActions.showRequest("You can now use the button.", "1"); //TEMPORARY (THIS IS LIKE A CUSTOM ALERT)'
}
setTimeout(fct, 200);
}
]]>
</function>
</loadChrome2>
Despite my best efforts I cannot see why this is happening. I thought about making a video presentation to try and help you understand but maybe Skype would better, if you had time of course. I'm sorry this is taking up so much of your time already. Anyway, my brain is going a bit numb after a whole day battling with this. I think i'll quit for today. Thanks again for your help. I''ll be in touch .