I need to change zoom rate on different breakpoint for embed google my map. Map is embed in iframe like this
<iframe src="https://www.google.com/maps/d/embed?mid=ID_here&z=15" width="100%"></iframe>
As you can see, zoom is 15, but I need to change it on mobile and tablet devices.
Do you have idea how to do that?
Perhaps something like this:
<!DOCTYPE html>
<html>
<head><title>test</title></head>
<body>
<iframe
width="600"
height="450"
frameborder="0" style="border:0"
src="https://www.google.com/maps/embed/v1/place?key=AIzaSyBu9SPYB9qp2PTe1M1_TyBAQN4c-yL8HYQ
&q=Space+Needle,Seattle+WA&zoom=10" allowfullscreen>
</iframe>
<script>
function setEmbeddedMapZoom() {
var zoomForPhone = 15;
var defaultZoom = 10;
var baseSrc = 'https://www.google.com/maps/embed/v1/place?key=YOUR_API_KEY&q=Space+Needle,Seattle+WA&zoom=';
if (window.innerWidth < 1600) {
document.getElementsByTagName('iframe')[0].setAttribute('src', baseSrc + zoomForPhone);
} else {
document.getElementsByTagName('iframe')[0].setAttribute('src', baseSrc + defaultZoom);
}
}
window.addEventListener('resize', setEmbeddedMapZoom);
</script>
</body>
</html>
http://jsbin.com/tucanayiye/edit?html,output
Please note that I had to make sure the Embed API was turned on in the project where I created the API key.
function changeIframeSrc(index){
var iframeid = document.getElementByID('changingIframe');
iframeid.setAttribute('src', sourceList[index]);
}
var i = 0;
var sourceList = ['111.php', '222.php', '333.php'];
setInterval(function(){ changeIframeSrc(i++);
// loop properly
if(i == sourceList.length){ i = 0; }
}, 10000);
<iframe id="changingIframe" src="" scrolling="no" width="100%" height="87%"></iframe>
<html>
<body>
<div class="wrapper">
<iframe id="111" src="111.php" scrolling="no" width="100%"></iframe>
<iframe id="222" src="222.php" scrolling="no" width="100%"></iframe>
<iframe id="333" src="333.php" scrolling="no" width="100%"></iframe>
<iframe id="bottom_banner" src="bottom_banner.php" scrolling="no" width="100%"></iframe>
</div>
</body>
I want my page to change between pages 111,222,333 on a loop every 10 seconds.
I could use etc. on each page but my banner keeps duplicating on each loop. (therefore stacking up)
I want to keep my banner at the bottom at all times. I want my pages to take up 80% of the height and the banner to take up the 20% left over.
You could use Javascript/jQuery to change the source of the iframe that keeps changing source
So
function changeIframeSrc(index){
var iframeid = document.getElementById('changingIframe');
iframeid.setAttribute('src', sourceList[index]);
}
and then
var i = 0;
var sourceList = ['111.php', '222.php', '333.php', etc];
setInterval(function(){ changeIframeSrc(i++);
// loop properly
if(i == sourceList.length){ i = 0; }
}, 10000);
I'm having an issue with Iframe autoplay="0" on Google Chrome.
I have tried every thread and and forum and nothing has worked.
I need the video to pause as soon as the page loads. I cannot use the <video> </video> tag because I need information to pull from a separate library into a main video div.
I haven't found any JavaScript that works and autostart="0" , autostart="false" autoplay="0" , autoplay="false" doesnt work either.
Link : Aza TV
<script>
$(".video-1, .video-2, .video-3").on("click", function(event) {
event.preventDefault();
$(".video_case iframe").prop("src", $(event.currentTarget).attr("href"));
});
</script>
.video_wrapper { width:67%; padding:10px; box-sizing:border-box; float:left; min-height:50px;border: thin solid #F60; border-radius:5px 5px;}
.nextvideo_wrapper { width:31%; padding:8px; box-sizing:border-box; float:left; min-height:400px;border: thin solid #F60; border-radius:5px 5px;margin-left:10px; background:#333;}
<div class="video_wrapper">
<iframe name="someFrame" id="someFrame" width="100%" height="420" src="http://41.76.210.2/vod/azamusica_VictoriaKimani_webisode22_20151022_HDO.mp4?autoplay=0" controls ></iframe>
</div>
<div class="nextvideo_wrapper">
<iframe src="libraries/azamuzika.php" width="100%" height="400px" bg=ffffff&text=000000" frameborder="0"></iframe>
</div>
Please note your selector does not actually match the html you posted.
To keep it simple try to add &autoplay=0 to your urls - if that does not work, try this - I gave the actual iframe an ID of iFrame1 and write the video tag into it
var vid = '<video controls="controls"><source src="__VIDEO__" type="video/mp4" /><!--[if gt IE 6]><object width="640" height="375" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"><! [endif]--><!--[if !IE]><!--><object width="640" height="375" type="video/quicktime" data="__VIDEO__.mp4"><!--<![endif]--><param name="src" value="__VIDEO__" /><param name="autoplay" value="false" /></object></video>';
$(".video-1, .video-2, .video-3").on("click", function(event) {
event.preventDefault();
var ifrm = $('#iFrame1').get(0); // get the DOM object
ifrm = (ifrm.contentWindow) ? ifrm.contentWindow : (ifrm.contentDocument.document) ? ifrm.contentDocument.document : ifrm.contentDocument;
ifrm.document.write(vid.replace(/__VIDEO__/g,$(event.currentTarget).attr("href"));
ifrm.document.close();
});
I've tried all the possible solutions but nothing worked for local video bindings. I believe best solution would be to fix using jQuery.
$(document).ready(function () {
var ownVideos = $("iframe");
$.each(ownVideos, function (i, video) {
var frameContent = $(video).contents().find('body').html();
if (frameContent) {
$(video).contents().find('body').html(frameContent.replace("autoplay", ""));
}
});
});
Note: It'll find all the iframes on document ready and loop through each iframe contents and replace/remove autoplay attribute. This solution can be use anywhere in your project. If you would like to do for specific element then use the code under $.each function and replace $(video) with your iframe element id like $("#myIFrameId").
On a website I am building I have a vimeo video embedded. The client needs to keep the sound on the video obviously for people that find it on vimeo. However for her website the sound is just plain annoying. So I need to find a way to mute the audio within the code for the embed. I have googled it but can't seem to find anything legible. As you can see from my code below, I have used the autoplay command within the link I was hoping I could do a similar thing to mute the sound.
<iframe src="http://player.vimeo.com/video/4415083? title=0&byline=0&portrait=0&color=d01e2f&autoplay=1" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
Thanks
In case it helps anyone, Vimeo have added a 'background' parameter for embedding videos, that autoplays videos silently. In some cases that will be useful where people want to mute videos - this is their example:
<iframe src="https://player.vimeo.com/video/76979871?background=1"
width="500" height="281" frameborder="0" webkitallowfullscreen
mozallowfullscreen allowfullscreen></iframe>
For non-paying members
You just need to add the muted parameter. E.g.:
<iframe src="https://vimeo.com/48400332?autoplay=1&loop=1&muted=1" ></iframe>
For paid members
According to Vimeo, the background parameter is only supported for videos hosted by paid members.
Source: https://help.vimeo.com/hc/en-us/articles/115004485728-Autoplaying-and-looping-embedded-videos
you will be using setVolume api in your vimeo.. player.api('setVolume', 0);
it will be like this...
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//f.vimeocdn.com/js/froogaloop2.min.js"></script>
<iframe id="vimeo_player" src="http://player.vimeo.com/video/4415083?title=0&byline=0&portrait=0&color=d01e2f&autoplay=1&player_id=vimeo_player" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<script>
var iframe = $('#vimeo_player')[0],
player = $f(iframe),
status = $('.status');
player.addEvent('ready', function() {
player.api('setVolume', 0);
});
</script>
I tried the examples in the answers with no luck. After looking into the documentation I noticed there is missing the parameter &player_id=IFRAME_ID. Maybe something changed in the Vimeo API, anyway the following example works for me:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://f.vimeocdn.com/js/froogaloop2.min.js"></script>
<iframe id="vimeo_player" src="//player.vimeo.com/video/4415083?api=1&player_id=vimeo_player&autoplay=1&loop=1&color=ffffff" width="1920" height="1080" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<script>
$(function() {
var vimeo_iframe = $('#vimeo_player')[0];
var player = $f(vimeo_iframe);
player.addEvent('ready', function() {
player.api('setVolume', 0);
});
});
</script>
Seems like Vimeo is providing an updated library, and the API syntax is a bit different from the old one (Froogaloop). Here's how to mute an embedded video with JS:
<!--Add the id attr to the iframe tag to use as a selector-->
<iframe id="embeddedVideo" src="http://player.vimeo.com/video/4415083? title=0&byline=0&portrait=0&color=d01e2f&autoplay=1" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<!--Include the Vimeo API Library-->
<script src="https://player.vimeo.com/api/player.js"></script>
<!--Select and manipulate your video-->
<script type="text/javascript">
//Select the #embeddedVideo element
var video = document.getElementById('embeddedVideo');
//Create a new Vimeo.Player object
var player = new Vimeo.Player(video);
//When the player is ready, set the volume to 0
player.ready().then(function() {
player.setVolume(0);
});
</script>
Hope this helps out anyone who's using the new library. Documentation is at vimeo/player.js
Since most of the answers here are referring to Vimeo's old api. Here is the simplest way with the new api. You can include vimeo player.js from their CDN or you can download it or you can include it from npm.
<script src="https://player.vimeo.com/api/player.js"></script>
or
npm install #vimeo/player
then you can do the following.
<script>
var iframe = document.querySelector('iframe');
var player = new Vimeo.Player(iframe);
player.setVolume(0);
</script>
that's it. And if you are using angular 2+,
import * as Vimeo from '#vimeo/player';
const iframe = e.target;
const player = new Vimeo(iframe);
player.setVolume(0);
here e.target is $event which would be passed from the template. Probably it could be iframe (load) event. Or may be you can use jquery to select iframe.
#Gadss answer works great but I found that you need update the iframe src to include the activation of the Vimeo api. Just include api=1 after the vimeo id.
I've also found that this sometimes doens't work on Safari for some reason.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//f.vimeocdn.com/js/froogaloop2.min.js"></script>
<iframe id="vimeo_player" src="http://player.vimeo.com/video/4415083?api=1&title=0&byline=0&portrait=0&color=d01e2f&autoplay=1" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<script>
var iframe = $('#vimeo_player')[0],
player = $f(iframe),
status = $('.status');
player.addEvent('ready', function() {
player.api('setVolume', 0);
});
</script>
**Here is my solution:
http://jsfiddle.net/jakeoblivion/phytdt9L/5/
(You will need your own play/pause mute/unmute icons)
//load video muted
var video = $("#myvideo");
video.vimeo("play");
video.vimeo("setVolume", 0);
//toggle play/pause
$('#play-pause').click(function() {
$(this).toggleClass('play');
if ($(this).hasClass('play')) {
//pause video
video.vimeo("pause");
$(this).css('background', 'pink');
} else {
//unpause video
video.vimeo("play");
$(this).css('background', 'blue');
}
});
//toggle mute/unmute
$('#mute-unmute').click(function() {
$(this).toggleClass('mute');
if ($(this).hasClass('mute')) {
//unmute video
video.vimeo("setVolume", 1);
$(this).css('background', 'green');
} else {
//mute video
video.vimeo("setVolume", 0);
$(this).css('background', 'red');
}
});
Spent ages trying and nothing seemed to work to.
I just wanted to have a Vimeo autoplay muted (volume 0) with simple Play/Pause Mute/Unmute controls, instead of their default ones. (feel free to use icons instead of the temporary colours I put).
(if you want to add the default controls back but keep muted, remove "?background=1". By default background=1 will set video.vimeo("setVolume", 0) and hide controls, so I also added the mute on load without the background=1 set).
Also note:
"You’ll need to be running on a web server instead of opening the file directly in your browser. JS security restrictions will prevent the API from working when run locally."
I've found a way to do it. You start the video muted so it autoplays, then on the first timeupdate you set the volume to 1.
var options = {
id: 'video_id_here',
width: 640,
loop: false,
muted: true,
autoplay: true
};
var player = new Vimeo.Player('vimeo', options);
player.setVolume(0);
player.on('timeupdate', set_autoplay_volume );
function set_autoplay_volume(){
player.setVolume(1);
player.off('timeupdate', set_autoplay_volume );
}
You try insert ?muted=1 after link in attribute src
For example
<iframe id="vimeo_player" src="https://player.vimeo.com/video/257992348?muted=1">
This is the only way it worked for me: http://jsfiddle.net/87dsjL8q/108/
var iframe = document.getElementsByTagName('iframe')[0];
var player = $f( iframe );
player.addEvent('ready', function() {
player.api('setVolume', 20);
});
<iframe src="http://player.vimeo.com/video/4415083?muted=1; title=0;byline=0;portrait=0;color=d01e2f;autoplay=1" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
you can just give "muted=1" so the video will be muted...
chrome allow the videos autoplay that are muted
<html>
<head>
<script type = "text/javascript">
function changeone() {
parent.document.getElementByID("frame2").src= "www.MyWebsite.com"
}
</script>
</head>
<body>
<iframe id= "frame1" src= "CustomPageCreated.html" width="300" height="500" frameborder="1" scrolling="auto" onload = changeone() > </iframe>
<iframe id= "frame2" width="300" height="500" frameborder="1" scrolling="auto" > </iframe>
</body>
</html>
The custom page loads in the frame but the www.mywebsite.com does not load in the 2nd frame, Is there anything wrong with the code.
Your DOM probably hasn't fully loaded. In addition to the changes #sroes mentioned, try putting the script tag right before the closing </body> tag. The following works for me.
<iframe id="frame1" style="width:400px;height:400px;" onLoad="loadSite2();"></iframe>
<iframe id="frame2" style="width:400px;height:400px;"></iframe>
<script>
var site1 = 'http://rice.edu',
site2 = 'http://bing.com';
function loadSite2() {
document.getElementById('frame2').src = site2;
}
document.getElementById('frame1').src = site1;
</script>
Try to remove parent. and change document.getElementByID to document.getElementById:
document.getElementById("frame2").src= "http://www.MyWebsite.com"
Edit:
Also make sure you add quotes to the onload attribute:
<iframe id= "frame1" src= "CustomPageCreated.html" width="300" height="500" frameborder="1" scrolling="auto" onload="changeone()"> </iframe>