0

I am trying to take the inputed value from here: index.html

<form name="ytenter" action="youtbe.html" method="get">
url: <input type="text" id="url"name="url">
stop <input type="text" id="stop" name="stop">
<input type="submit" value="Submit" onclick="ytstop(this.stop)">
</form>

and take the entered value in id=url and id=stop

and run it to youtbe.html here:

<head>

<script>
(function ytstop() {

var stopPlayAt=10; // Stop play at   time in seconds

var stopPlayTimer; // Reference to settimeout call

   // This code loads the IFrame Player API code asynchronously.
var tag = document.createElement("script");
tag.src = "//www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName("script")[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

// This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player;
window.onYouTubeIframeAPIReady = function () {
    player = new YT.Player("player", {
        "height": "315",
            "width": "560",
            "videoId": "L6cVcbkx8l8",
            "events": {
            "onReady": onPlayerReady,
                "onStateChange": onPlayerStateChange
        }
    });
}

// The API will call this function when the video player is ready.
// This automatically starts the video playback when the player is loaded.
function onPlayerReady(event) {
    event.target.playVideo();
}

// The API calls this function when the player's state changes.
function onPlayerStateChange(event) {
    var time, rate, remainingTime;
    clearTimeout(stopPlayTimer);
    if (event.data == YT.PlayerState.PLAYING) {
        time = player.getCurrentTime();
        // Add .4 of a second to the time in case it's close to the current time
        // (The API kept returning ~9.7 when hitting play after stopping at 10s)
        if (time + .4 < stopPlayAt) {
            rate = player.getPlaybackRate();
            remainingTime = (stopPlayAt - time) / rate;
            stopPlayTimer = setTimeout(pauseVideo, remainingTime * 1000);
        }
    }
}

function pauseVideo() {
    player.pauseVideo();
}
})();

</script>







</head>

<body>

<div id="player">

</div>


</html>

I need to take the "stop" from the form and put it into stopPlayAt VAR at the top

Then I need to take "url" entered from the form and put it into "videoID":

Thanks for your help. Just want the end product to allow youtube link to be entered and a time to be entered and it runs it until that time entered in seconds.

1 Answers1

0

I would like to refer you to the top answer on this page: How to get the value from the GET parameters?

This enables you to get the value of the GET-parameters in the URL.

Community
  • 1
  • 1
Etienne Bruines
  • 2,848
  • 3
  • 17
  • 25