Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8128989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:07:15+00:00 2026-06-06T08:07:15+00:00

I believe I’m having a relatively simple problem with a video player implementation in

  • 0

I believe I’m having a relatively simple problem with a video player implementation in javascript. To start, I want to add a string to an array and reference that first string entry as the src of my source in my video tag. I then want the video to begin playing once the src is received.

I have not implemented the code for the latter since I haven’t gotten past the former yet. I’ve seen people make reference to a .load() function call after changing the src but I don’t know if I’m correctly setting the src to begin with.

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Untitled Document</title>

<style>

video
{
    background-color:#333;
}

</style>

</head>

<body>

<script type="text/javascript">
var width = (1280 * 0.1);
var height = (720 * 0.1);
var resized = false;

function getWidth(){
    return width;
}

function getHeight(){
    return height;
}


//Create array. Checkbox adds video to list.
//"Submit" button gives first video in list to player.

var videoList = new Array();
var i = 0; //incrementer

//Use checkbox's value as argument
function addVideo(value){
    videoList[i] = value;
    i++;
}

function videoSubmit(){
    document.getElementById("player").setAttribute("src", videoList[i]);
}

</script>

<video id="test" width="getWidth()" height="getHeight()">
<source id="player" src="null" type="video/avi" width="getWidth()"     height="getHeight()"/>

</video>
<br/>

<form id="selector" action="">
<input type="checkbox" name="firstvideo" value="test.avi" onClick="addVideo(test.avi)"/> sample 1.avi<br/>

</form>

<button onClick="videoSubmit()"> Submit</button>


</body>
</html>

I’m quite new to javascript and am still trying to wrap my head around it. Any helpful information is greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T08:07:17+00:00Added an answer on June 6, 2026 at 8:07 am

    Looks like i has the wrong value. Try:

    function videoSubmit(){
        document.getElementById("player").setAttribute("src", videoList[ i - 1 ]);
    }
    

    There are a few other issues as well. Here’s a fixed version – enjoy:

    http://jsfiddle.net/mrSYC/

    Another problem:

    You can’t do this:

    <video id="test" width="getWidth()" height="getHeight()">
    

    If you want to programatically set those attributes, you must do it the same way you are with the src attribute. Sometimes you’ll see this sort of construct, but it’s clumsy:

    <script>document.write('<video id="test" width="' + getWidth() + '" ...')</script>
    

    Unrelated to the Q – you could skip a lot of javascript learning pain by jumping straight to jquery. It does incur a page-load penalty, but it cures a lot of the annoyances of pure javascript. Doing it the old fashioned way will give you “valuable experience” – which those of us who have it value probably more than warranted.

    http://jquery.com/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I believe I am having a security problem related to using the embed tag
I believe I understand how submodule work, but in my case I don't want
I believe it is a simple mistake but I have spent a lot of
I believe my problem relates to scope somehow, as I'm a js newbie. I
I believe our problem is that we need to run particular builds on a
I believe I have a simple question.... but for me as beginner, I can't
I believe the major problem comes from the read method in MicrophoneManager but cant
I believe the answer may be quite simple but i cant find the answer
I believe this might be one of the most common problem that users faces
I believe this has been a bug/problem in SQL 2000/2005 ... If my results

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.