Foros del Web » Programando para Internet » Javascript »

cambiar volores de alto y ancho de videos

Estas en el tema de cambiar volores de alto y ancho de videos en el foro de Javascript en Foros del Web. Hola a todos me gustaria saber como puedo cambiar los valores del alto y el ancho de un video embevido en mi web con javaScript ...
  #1 (permalink)  
Antiguo 20/11/2009, 05:30
 
Fecha de Ingreso: febrero-2009
Mensajes: 147
Antigüedad: 15 años, 2 meses
Puntos: 1
Exclamación cambiar volores de alto y ancho de videos

Hola a todos me gustaria saber como puedo cambiar los valores del alto y el ancho de un video embevido en mi web con javaScript .
Lo que quiero hacer es insertar dos botones uno q sea agrandar y otro Restaurar
y q al pulsar sobre estos botones se haga mas grande el video o mas pequeño
se que tengo que coloca variables pero no se capturar el valor de esas variables en las funciones que tengo que llamar para poder cambiar el alto y el ancho del video
Muchisimas Gracias de antemano
  #2 (permalink)  
Antiguo 20/11/2009, 05:48
Avatar de Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 17 años, 4 meses
Puntos: 126
Respuesta: cambiar volores de alto y ancho de videos

Hola

Cita:
document.getElementById('elvideo').style.width=anc ho_video;
document.getElementById('elvideo').style.height=al to_video;
donde ancho_video y alto_video son el valore de los argumentos que le has pasado a la función

Suerte
__________________
Los formularios se envían/validan con un botón Submit
<input type="submit" value="Enviar" style="background-color:#0B5795; font:bold 10px verdana; color:#FFF;" />
  #3 (permalink)  
Antiguo 20/11/2009, 05:54
 
Fecha de Ingreso: febrero-2009
Mensajes: 147
Antigüedad: 15 años, 2 meses
Puntos: 1
Respuesta: cambiar volores de alto y ancho de videos

Esto ya lo havia intentado pero lo q consigo es agrandar la capa no el video
Gracias de toda de todas formas
  #4 (permalink)  
Antiguo 20/11/2009, 05:56
Avatar de Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Respuesta: cambiar volores de alto y ancho de videos

En realidad depende del tipo de video y cómo esté incrustado. No es lo mismo si estás hablando del tag video o de un video .mov o windows-media o flash. Tampoco es lo mismo si está incrustado con innerHTML o con swfObject o AC_RunActiveContent. Deberás suministrar más datos para obtener una ayuda más eficaz.
  #5 (permalink)  
Antiguo 20/11/2009, 05:59
 
Fecha de Ingreso: febrero-2009
Mensajes: 147
Antigüedad: 15 años, 2 meses
Puntos: 1
Respuesta: cambiar volores de alto y ancho de videos

Cita:
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/GUj829kvjck&hl=es_ES&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/GUj829kvjck&hl=es_ES&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>
el tipo de embebido es el de youtube normal

Yo quiero hacer algo simila a lo que hace Tuenti con los videos q tiene un boton donde los hace mas grande o mas pequeños
y perdonen por la falta de informacion
  #6 (permalink)  
Antiguo 20/11/2009, 06:00
 
Fecha de Ingreso: febrero-2009
Mensajes: 147
Antigüedad: 15 años, 2 meses
Puntos: 1
Respuesta: cambiar volores de alto y ancho de videos

Yo quiero hacer algo simila a lo que hace Tuenti con los videos q tiene un boton donde los hace mas grande o mas pequeños
y perdonen por la falta de informacion
  #7 (permalink)  
Antiguo 20/11/2009, 06:05
Avatar de Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 17 años, 4 meses
Puntos: 126
Respuesta: cambiar volores de alto y ancho de videos

Hola

Ok te doy el código que se basa en lo que te mencioné anteriormente. Solo has de editarlo para adaptarlo a tus necesidades

Código javascript:
Ver original
  1. <html>
  2. <head>
  3. <title></title>
  4. <script type="text/javascript">
  5. function solonumeros(evt) {
  6. var keyPressed = (evt.which) ? evt.which : event.keyCode
  7.     return !(keyPressed > 31 && (keyPressed < 48 || keyPressed > 57));
  8. }
  9.  
  10.  
  11. function calculalo() {
  12.     document.getElementById('elalto').value=parseInt((document.getElementById('elancho').value*662)/994);
  13. }
  14.  
  15.  
  16. var ieNOTopera=document.all&&navigator.userAgent.indexOf("Opera")==-1
  17. function iecompattest() {
  18.     return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
  19. }
  20.  
  21.  
  22.  
  23. function cambialo() {
  24. // Esto ha de estar antes que var cabecera_height
  25. var ancho_video = document.getElementById('elancho').value;
  26. var alto_video = document.getElementById('elalto').value;
  27.     document.getElementById('elvideo').style.width=ancho_video;
  28.     document.getElementById('elvideo').style.height=alto_video;
  29. // Fin condicion
  30.  
  31. var window_height = ieNOTopera? iecompattest().clientHeight : window.innerHeight;
  32. var window_width = ieNOTopera? iecompattest().clientWidth : window.innerWidth;
  33. //FF
  34. //var cabecera_height = document.getElementById('contenido').clientHeight;
  35. //var pie_height = document.getElementById('pie').clientHeight;
  36. //var cabecera_width = document.getElementById('contenido').clientWidth;
  37. //IE
  38. //var cabecera_height = document.getElementById('contenido').scrollHeight;
  39. //var pie_height = document.getElementById('pie').scrollHeight;
  40. //var cabecera_width = document.getElementById('contenido').scrollWidth;
  41.  
  42. if (document.Element || document.body){
  43. var cabecera_height = document.getElementById('contenido').scrollHeight;
  44. var pie_height = document.getElementById('pie').scrollHeight;
  45. var cabecera_width = document.getElementById('contenido').scrollWidth;
  46. } else {
  47. var cabecera_height = document.getElementById('contenido').clientHeight;
  48. var pie_height = document.getElementById('pie').clientHeight;
  49. var cabecera_width = document.getElementById('contenido').clientWidth;
  50. }
  51.  
  52.  
  53. var total_Height = parseInt(cabecera_height) + parseInt(pie_height);
  54.  
  55. //alert("Ventana disponible largo " + window_height)
  56. //alert("Ventana disponible ancho " + window_width)
  57. //alert("Ancho Video " + ancho_video)
  58. //alert("Ancho Cabecera " + cabecera_width)
  59. //alert("Total " +total_Height)
  60.  
  61.  
  62.  
  63.         if (total_Height < window_height) {
  64.             document.getElementById('veocine').style.height= window_height;
  65.         }
  66.         else
  67.         {
  68.             document.getElementById('veocine').style.height=total_Height;
  69.         }
  70.  
  71.         if (ancho_video < cabecera_width) {
  72.             document.getElementById('veocine').style.width=window_width;
  73.         }
  74.         else
  75.         {
  76.             document.getElementById('veocine').style.width=parseInt(ancho_video)+20;
  77.         }
  78.  
  79. }
  80.  
  81.  
  82.  
  83.  
  84. function modocine() {
  85. var cuentanos = 0;
  86. var decimas = 0;
  87. document.getElementById('veocine').style.display='';
  88. while (cuentanos < 80) {
  89. decimas = cuentanos/100;
  90. document.getElementById('veocine').style.filter='alpha(opacity='+cuentanos+')';
  91. document.getElementById('veocine').style.MozOpacity=decimas;
  92. document.getElementById('veocine').style.opacity=decimas;
  93. document.getElementById('veocine').style.khtmlOpacity=decimas;
  94. cuentanos += 10;
  95. cuentanos = parseInt(cuentanos);
  96. }
  97. document.getElementById('modocine').style.display='none';
  98. document.getElementById('modocine').style.visibility='hidden';
  99. document.getElementById('modonormal').style.display='';
  100. document.getElementById('modonormal').style.visibility='visible';
  101. }
  102.  
  103.  
  104. function modonormal() {
  105. var cuentanos = 100;
  106. var decimas = 1;
  107. document.getElementById('veocine').style.display='none';
  108. while (cuentanos <= 80) {
  109. decimas = cuentanos/100;
  110. document.getElementById('veocine').style.filter='alpha(opacity='+cuentanos+')';
  111. document.getElementById('veocine').style.MozOpacity=decimas;
  112. document.getElementById('veocine').style.opacity=decimas;
  113. document.getElementById('veocine').style.khtmlOpacity=decimas;
  114. cuentanos -= 10;
  115. cuentanos = parseInt(cuentanos);
  116. }
  117. document.getElementById('modonormal').style.display='none';
  118. document.getElementById('modonormal').style.visibility='hidden';
  119. document.getElementById('modocine').style.display='';
  120. document.getElementById('modocine').style.visibility='visible';
  121. }
  122.  
  123.  
  124. function opacidad(valor) {
  125. cuentanos = document.getElementById('veocine').style.MozOpacity*100;
  126. switch (valor) {
  127. case "mas":
  128. if(cuentanos < 100) {
  129. cuentanos += 10;
  130. cuentanos = parseInt(cuentanos);
  131. decimas = cuentanos/100;
  132. document.getElementById('veocine').style.filter='alpha(opacity='+cuentanos+')';
  133. document.getElementById('veocine').style.MozOpacity=decimas;
  134. document.getElementById('veocine').style.opacity=decimas;
  135. document.getElementById('veocine').style.khtmlOpacity=decimas;
  136. }
  137. break;
  138. case "menos":
  139. if(cuentanos > 30) {
  140. cuentanos -= 10;
  141. cuentanos = parseInt(cuentanos);
  142. decimas = cuentanos/100;
  143. document.getElementById('veocine').style.filter='alpha(opacity='+cuentanos+')';
  144. document.getElementById('veocine').style.MozOpacity=decimas;
  145. document.getElementById('veocine').style.opacity=decimas;
  146. document.getElementById('veocine').style.khtmlOpacity=decimas;
  147. }
  148. break;
  149. }
  150. }
  151. </script>
  152. </head>
  153. <body>
  154.  
  155.  
  156. <div id="contenido" align="center" style="" valign="top">
  157. <div id="veocine" style="overflow: auto; display: none; opacity: 0; position: absolute; width: 100%; height: 100%; z-index: 2; left: 0px; top: 0px; background-color: rgb(0, 0, 0);">
  158. <div id="modonormal" style="margin-top: 20px; display: none;">
  159. <input type="button" onclick="modonormal()" value="Desactivar Modo Cine"/>
  160. <input type="button" onclick="opacidad('menos')" value="-"/>
  161. <input type="button" onclick="opacidad('mas')" value="+"/>
  162. </div>
  163. </div>
  164.  
  165. <div align="center">
  166. <i><font color="red">* Introduce unos valores numericos para cambiar el tamaño del video (ancho/alto)</font></i>
  167. <br/>
  168. <i><font color="red">* el cambio de tamaño no resetea la carga del video, puedes usarlo sin problemas.</font></i>
  169. <div>
  170. ANCHO: <input id="elancho" type="text" onkeypress="return solonumeros(event)" onkeyup="calculalo()" maxlength="4" size="10" value="390"/>
  171. ALTO: <input id="elalto" type="text" disabled="disabled" onkeypress="return solonumeros(event)" maxlength="4" size="10" value="259"/>
  172. <input type="button" onclick="cambialo()" value="Cambiar Tamaño"/>
  173. <input type="button" id="modocine" onclick="modocine()" value="Activar Modo Cine"/>
  174. </div>
  175.  
  176.  
  177. <div style="z-index:3;">
  178. <center>
  179. <object width="390px" height="259px">
  180. <param name="movie" value="http://www.youtube.com/v/3BPDMXhXeAU&hl=es&fs=1&"></param>
  181. <param name="allowFullScreen" value="true"></param>
  182. <param name="allowscriptaccess" value="always"></param>
  183. <embed id="elvideo" src="http://www.youtube.com/v/3BPDMXhXeAU&hl=es&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="390px" height="259px"></embed>
  184. </object>
  185. </center>
  186. </div>
  187.  
  188. <br/>
  189.  
  190. <div id="pie" align="center" style="z-index: 3; font-family: verdana,arial; font-size: 12px; font-weight: bold;position:relative; bottom:2px;">
  191. Copyright 2008-2009.
  192. <br/>
  193. Todos los videos son externos a nosotros.
  194. </div>
  195.  
  196. </body>
  197. </html>

Suerte
__________________
Los formularios se envían/validan con un botón Submit
<input type="submit" value="Enviar" style="background-color:#0B5795; font:bold 10px verdana; color:#FFF;" />
  #8 (permalink)  
Antiguo 20/11/2009, 06:06
 
Fecha de Ingreso: febrero-2009
Mensajes: 147
Antigüedad: 15 años, 2 meses
Puntos: 1
Respuesta: cambiar volores de alto y ancho de videos

muchas gracias!!!
  #9 (permalink)  
Antiguo 20/11/2009, 06:21
Avatar de Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Respuesta: cambiar volores de alto y ancho de videos

Probá algo así:
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<script>
var w=425;
var h=344;
var em='<object width="{w}" height="{h}"><param name="movie" value="http://www.youtube.com/v/GUj829kvjck&hl=es_ES&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/GUj829kvjck&hl=es_ES&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="{w}" height="{h}"></embed></object>';
function setMedida(w,h){
	window.w=w;
	window.h=h;
	var r=em.replace(/\{[^\}]*\}/g, function(key){
        return window[key.slice(1,-1)];
        });
	document.getElementById('video').innerHTML=r;

}
onload=function(){
	setMedida(425,344);
}
</script>
</head>

<body>
<div id="video"></div>
<form>
<input type="button" value="+" onclick="setMedida(w*1.1,h*1.1)" />

<input type="button" name="Submit" value="-" onclick="setMedida(w/1.1,h/1.1)"  />
</form>
</body>
</html>
Ah, veo que se me adelantaron, ja, ja.

Última edición por Panino5001; 20/11/2009 a las 06:28
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:39.