Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Embedding a video using dimesions of frame

Posted on 2009-04-24
5
Medium Priority
?
392 Views
Last Modified: 2013-11-19
Hi, Im trying to embed a quicktime video with the same dimensions as the frame that it is being displayed in. I've been trying to use a javascript function to return the frame size when called by the embedded video tag. I say that the width = Width() and the Width() function just returns the frame width. I put a button that creates an alert box that shows the dimensions of the frame and it works fine. All the embedded video does is play in something like 100x100. I use firefox
<html>
<head>
 
 
</head>
 
<body>
<script type="text/javascript">
function Height()
{
return document.body.clientHeight;
}
 
function Width()
{
return document.body.clientWidth;
}
</script>
<center>
<form>
<input type="button" onClick="alert(Height() + 'x' + Width());" value="Dimensions">
</form>
</center>
<br>
<br>
<embed src="9-tsr_720p.mov" width="Width()" height="Height()" scale="aspect" controller = "false">
 
</body>
 
</html>

Open in new window

0
Comment
Question by:sunnymock
  • 3
4 Comments
 
LVL 19

Expert Comment

by:v2Media
ID: 24230804
try

<embed src="9-tsr_720p.mov" width="javascript:Width()" height="javascript:Height()" scale="aspect" controller = "false">
0
 

Author Comment

by:sunnymock
ID: 24238257
It doesn't work :(. I'm wondering if the embed thing gets called before the frame dimensions don't exist when the embedding takes place. Does it? I just need a way to make the video the same size as the frame. I use the latest firefox.
0
 

Accepted Solution

by:
sunnymock earned 0 total points
ID: 24255660
After much struggling, a friend took a couple minutes after looking at it and solved it.
<html>
<head>
<script type="text/javascript">
function Height()
{
return document.body.clientHeight;
}
 
function Width()
{
return document.body.clientWidth;
}
function AspectRatio(height, width)
{
	return height/width;
}
</script>
</head>
<body>
<center>
<form>
<script>
var h=Height();
var w=Width();
document.write('<embed src=\"9-tsr_720p.mov\" width=' + w + ' height=' + h + ' scale=\"aspect\" controller=\"false\">');
</script>
</form>
</center>
</body>
</html>

Open in new window

0
 

Author Comment

by:sunnymock
ID: 24281044
Even better, I found code online that resizes images according to frame size. It doesn't use the right aspect ratio but once you use the scale = "aspect", the video is the right size.
http://www.vbforums.com/archive/index.php/t-208380.html

<html>
<head>
<script type="text/javascript">
function window_onresize() 
{
myVideo.height = window.document.body.clientHeight
myVideo.width = window.document.body.clientWidth
}
</script>
</head>
 
<body onload="return window_onresize()" onresize="return window_onresize()">
 
<center>
<form>
<embed id="myVideo" src="9-tsr_720p.mov" scale="aspect" controller="false">
</form>
</center>
 
</body>
</html>

Open in new window

0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Geo-targeting is the practice of distributing content based on a person’s location, as best as you can determine it. Let’s look at some ways you could successfully use this tactic. The following tips and case studies could lead to meaningful results.
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question