I am working on an Automated Tumblr blog and noticed that you can't post Twitch streams as a video post, however when you embed them you can.
There are going to be multiple users and it will be expanding, so I am trying to automate the script in IFTTT, however, I don't have much scripting knowledge and tried to get this done... didn't work out.
The question:
It all starts with the content link, this can really be any platform. However, all platforms that aren't supported by Tumblr need a different embed.
So what I want is a script (not asking for the script, just help) that can detect what platform the link is from and chooses a path on what it found out.
Basically, a script that checks if it's twitch, run a, if it's youtube run b, etc.
If the input contains "Twitch" run:
<html>
<body>
<div id="twitch-embed"></div>
<script src="https://embed.twitch.tv/embed/v1.js"></script>
<script type="text/javascript">
new Twitch.Embed("twitch-embed", {
width: 854,
height: 480,
channel: "{channel Name}"
});
</script>
</body>
</html>
If YouTube:
<script type="text/html" id="Video URL here">
How do I create these checks?
(I know this question is stupid and probably easy, but I am not really big on scripting)
You can take the URL string and check it against each keyword to determine if it exists:
var urlString = "https://www.twitch.tv/Reco_Mouse";
if(urlString.indexOf("twitch.tv") !== -1) {
//First, dynamically include the Twitch script tag on the page
new Twitch.Embed("twitch-embed", {
width: 854,
height: 480,
channel: "{channel Name}"
});
break;
} else if(urlString.indexOf("youtube.com") !== -1) {
//Apply necessary steps for YouTube videos
} else if(urlString.indexOf("anothervideotype.com") !== -1) {
... //Apply necessary steps for another video type
}
Related
I have a social netowork coded in PHP and css. Ive realized that it looks so much nicer and cleaner when its zoomed out at 90% instead of 100%. Is there a piece of code I can implement into the php or css to make the webpage automatically zoom out when its visited? This is mainly only for the login page.
if you want to take a look at the site, heres the URL: social.flamboyantent.co.uk
Thank you in advance.
If I understood you right.
This should work:
<script type="text/javascript">
function zoom() {
document.body.style.zoom = "90%"
}
</script>
<body onload="zoom()">
To add zoom in Firefox read this object.Style.Zoom property not working in Firefox
Last answer will work for major browsers.
<script type="text/javascript">
function zoom() {
document.body.style.zoom = "90%"
}
This is the compatibility chart.
But as stated in THIS QUESTION
You could use the "proprietary" -moz-transform property in Firefox 3.5+.
So you could use:
div.zoomed {
zoom: 3;
-moz-transform: scale(3);
-moz-transform-origin: 0 0;
}
And there´s also a BUGZILLA ticket.
Bugzilla
I have a wp site that in a lot of posts i am using youtube videos embeded with the clasic iframe.
Is possible to find the iframe div inside post and replace it with a custom youtube code?
I want to use the code bellow to control youtube video. When it starts, when it is finished.
The code that i have in my posts is:
<iframe width="824" height="464" src="//www.youtube.com/embed/eEqIBzxHjiA?rel=0" frameborder="0" allowfullscreen></iframe>
And i want to replace it with:
<script>
// create youtube player
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: 'eEqIBzxHjiA',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
// autoplay video
function onPlayerReady(event) {
event.target.playVideo();
}
// when video ends
function onPlayerStateChange(event) {
if(event.data === 0) {
alert ('FInished');
}
}
</script>
Thank you guys...
use shortcodes
1. The WordPress Rich Editor might strip out JavaScript src tags so best is to write a little plugin that defines a shortcode e.g. [myyoutube id=eEqIBzxHjiA] and use that one from now on. Probably you want to define a javascript .js file that holds the main code and include that in each page where the shortcode is present. So all of the above except the player ID will be in the included .js file that you define in the shortcut code. only the playerId is then a call to the javascript function.
legacy
2. For all the existing entries: probably the fastest to use a sql command on the database posts table and replace all entries matching the regex above with the new shortcode tag. (fastest way)
How to make video play on web by using url, but can not access by direct link ?
Now I use jw player
<script type="text/javascript">
jwplayer("mediaplayer1889082201").setup({
flashplayer: "jwplayer/jwplayer.flash.swf",
file: "http://testhost.com/myproject/files/1/video/coursecreeklruprr4nags7ee1codeschool_756.mp4",
image: "http://testhost.com/myproject/files/1/video/coursecreeklruprr4nags7ee1codeschool_756.jpg",
width: "800",
height: "510",
stretching: "uniform",
skin: "jwplayer/jwplayer-skins-free/six.xml",
abouttext: "myproject",
aboutlink: "myproject",
});
</script>
So I can using http://testhost.com/myproject/files/1/ to access to folder (Look this link by inspect element)
I want video play on jw player.But i don't want user on web access by direct url to folder that contain video.
Thaks you.
Ok, I understand you want to serve the video file to the script, but you don't want users being able to navigate to the video url and download/view it from there.
A quick example using PHP
Change your code to:
<script type="text/javascript">
jwplayer("mediaplayer1889082201").setup({
flashplayer: "jwplayer/jwplayer.flash.swf",
file: "video.php?file=coursecreeklruprr4nags7ee1codeschool_756.mp4",
image: "http://testhost.com/myproject/files/1/video/coursecreeklruprr4nags7ee1codeschool_756.jpg",
width: "800",
height: "510",
stretching: "uniform",
skin: "jwplayer/jwplayer-skins-free/six.xml",
abouttext: "myproject",
aboutlink: "myproject",
});
</script>
As you can see, we are sending a file request to video.php, then we'll create that file serving the video only when the referrer is your webpage which will be able to show it.
Go ahead and create video.php in the same folder.
First we need to check if a file has been given in the url, like this:
<?php
if(isset($_GET['file']) {
}
Then we check if the referrer is your page, like this:
if (strpos($ref,'testhost.com/myproject/files/1') !== 0){
}
If it's your page we can start serving your file, like this:
$path = 'video/' . $_GET['file'];
header("X-Sendfile: $path");
So the whole thing together:
<?php
if(isset($_GET['file']) {
if (strpos($ref,'testhost.com/myproject/files/1') !== 0){
$path = 'video/' . $_GET['file'];
header("X-Sendfile: $path");
}
}
Look out; this is a very quick EXAMPLE, not a safe-and-ready-to-use-script! Their has to be security checks build in, and you're serving a file even when it's not existing, so that kind of checks still has to be made to make it ready for use.
Good luck with your project.
Under:
stretching: "uniform",
Add:
type: "mp4",
This way, the JW Player can read the file if it does not have a file extension.
I would like to be able to display on a web page that a twitter user was "last seen" in X location, "where he said" whatever their latest tweet is. This is for a user that has geolocation enabled, and I am doing this to track them on a trip. What is the easiest way to do this? It would look like this:
[user] was last seen in [latest tweet location (city/state, not geopoints)] where he said: [latest tweet]
Any help/advice is appreciated.
UPDATE:
I have tried this adding this to the page:
<script type="text/javascript" src="http://mywebsite.com/blogger.js"></script>
<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/username.json?callback=twitterCallback2&count=1"></script>
<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/username.json?callback=twitterLocation&count=1"></script>
And then modifying twitter's blogger.js to add this at the top:
function twitterLocation(twitters) {
var statusHTML = [];
for (var i=0; i<twitters.length; i++){
var place= twitters[i].place.full_name;
statusHTML.push('+place+');
}
document.getElementById('location').innerHTML = statusHTML.join('');
}
and finally, putting a
<span id="location></span>
and
<div id="twitter_update_list"></div>
in the html as well.
The tweet comes out okay, but the only thing placed in the "location" span is just the text, "+place"
Is it possible that I'm on any sort of right track here?
You should Google for the answer here, but I would simply use the REST API:
https://dev.twitter.com/docs/api/1/get/statuses/user_timeline
The last location would be in the "geo" parameter.
Then use the Google Reverse Geocoding API to pull out a location string:
https://developers.google.com/maps/documentation/geocoding/#ReverseGeocoding
I make a simple html page and set it on facebook fan page tab but the tab which shows on fan page is shows a scroll bar buti already set to auto resize and the height of this html page is large i want to hide the scroll bar and show the complete page
The best solution I found, which works for me is:
You need to setup the Facebook app canvas settings, Canvas height to Fluid.

Then, add some javascript in the page header:
<script type="text/javascript" src="https://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript" charset="utf-8">
FB.Canvas.setAutoResize();
</script>
Finally, force our body and html tag to avoid scroll bars in css.
body, html {
overflow:hidden;
}
This has worked for me to remove all the scroll bars. It's working on the 18th of October 2011, but because Facebook keep changing their code, it may change in the future.
A full article about Facebook iframe is available on my blog: http://gpiot.com/facebook-page-tab-hide-scroll-bars-from-iframe/
Thanks to all of you.
Here is the answer of my question; I posted it here so that if any body find this question in future will also get the answer and his/her time is not wasted. I get the solution by adding the following code just before the </body> tag of my index page
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.Canvas.setSize();
}
// Do things that will sometimes call sizeChangeCallback()
function sizeChangeCallback() {
FB.Canvas.setSize();
}
</script>
Once again, thanks to all.
This solution works for me
http://aarosant.com/2011/03/14/adjust-the-size-of-facebook-iframe-tabs/
GO TO the App Setting -> Advanced setting -> canvas page there you can change width and height to fixed from fluid