How to I check to see if the browser supports flash? - php

I have a flash banner that I want to replace with a static image if the clients browser doesn't have flash enabled.
I was wondering if I can do this with php - or if anyone knows of a good method
Thanks

Allow the <object> (your Flash movie) to degrade:
<object width="640" height="480">
<param name="movie" value="yourflash.swf">
<img src="yourimage.png">
</object>
This will show the image if the Flash video can't load, too.

You can only do this with javascript, using the navigator.plugins interface. Something like:
if(typeof navigator.plugins['Shockwave Flash']!=='undefined'){ }
However, a far more reliable solution that doesn't require any javascript would be simply to position your fallback image "behind" the flash object so that if the flash doesn't turn up, the image will show through. You can either put an <img/> tag inside the flash <object/> or you can put a CSS background-image on the object.

http://code.google.com/p/swfobject/
This is what I use when i need to embed flash and it checks for relavent support and what elements are needed.

I don't think you can check with PHP, you can do it with javascript or Actionscript from SWF file. Here is the official detection kit:
http://www.adobe.com/products/flashplayer/download/detection_kit/

You could use SWFobject
With SWFobject you display alternative code by default, e.g.
<div id="myContent">
<p>Alternative content</p>
</div>
This is then replaced where possible with flash content like this:
<script type="text/javascript">
swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0");
</script>
It does have a dependency on JavaScript though which is its only major drawback

Related

point browser to image and use jquery?

How can I manipulate image in browser with jquery when the image is retrieved with:
http://slideshopro.com/dunlap-hall-entry-tower/wp-content/uploads/sites/621/2014/06/DSC02599.jpg?imageOnly=true
I tried to put:
if($_GET['imageOnly'] == true) {
?>
<script type=text/javascript>
jQuery(document).ready(function($) {
console.log('image');
}
</script>
<?php
}
in index.php and in functions, but I could not get it to run.
Hard to tell exactly what you are asking here, but if you are talking about manually manipulating the image, that will be tough to do with jQuery alone, especially if you want to do something with the manipulated image. You will need to work HTML5 Canvas.
I suggest you check out fabric.js, they created a powerful and simple Javascript HTML5 canvas library.

Preloading pictures for refresh, cache

I have these two php variables: $img1src and $img2src, (them being PHP is irrelevant as you can echo a php variable anywhere) they both hold a URL of an image. I was wondering if I was able to preload these images, or cache them.
My goal is: when someone refreshes the page I want these pictures to instantly appear in a <img src >.
I'm not going to provide specific code, because I don't want to give you a fish, but rather show how google is a fishing pole.
I googled "php cache images tutorial" just to see what would come up. Below is a great resource.
http://dtbaker.com.au/random-bits/how-to-cache-images-generated-by-php.html
Can't get much better than that.
Caching an image isn't really a job for PHP. PHP should be used to decide whether or not to display it. (There are caching things you can do with PHP, but not in the same sense.) Essentially, what you want to do is make the clients browser request the second image. Once the browser gets the image, it should automatically send an "if-modified-by" parameter in the header. Next time you load the page, the response code should be 304 and your image should load instantly. You can choose from a variety of ways to do this. Load the image with javascript after the page has loaded (to prevent additional load time) or you can just include an image tag that is hidden on the page some where.
I also haven't tested it, but you might be able to send an ajax request to the image directly. I'm not sure if that way would cache it or not.
EDIT:
This isn't the most elegant solution, but it should get the idea across.
JS Example:
<?php
session_start();
if (!isset($_SESSION['graphic'])) $_SESSION['graphic'] = "http://www.tomsfreelance.com/laptop/DSC_0011.JPG";
else $_SESSION['graphic'] = "http://www.tomsfreelance.com/laptop/DSC_0012.JPG";
?>
<html>
<head>
<script>
function loadImage() {
document.getElementById('preload').style.backgroundImage = "url(http://www.tomsfreelance.com/laptop/DSC_0012.JPG)";
}
</script>
</head>
<body onload="loadImage();">
<div id="preload" style="display: none;"></div>
<img src="<?php echo $_SESSION['graphic'];?>">
</body>
</html>
Sure you can, try this javascript:
var image1 = new Image(), image2 = new Image();
image1.src = <?php echo $img1src; ?>;
image2.src = ?<php echo $img2src; ?>;
That should preload the image so when you append an img tag to the DOM the image should appear right away.
If your aim is to make less http requests overall: you can try CSS Sprites and/or Data Url methods of displaying these images. These methods will be the most effective when the images are smaller.

How to get proper soundcloud url for embedding from a standard url?

So right now I can grab the url from already embedded soundcloud files in embed or iframe tags and use those urls on another page and display it in fancybox. Is there a way to get the right url or display in fancybox if a user offers a typical share url such as http://soundcloud.com/song-b/song-please or http://snd.sc/yp6VMo? I tried looking at the api documentation but I couldn't really find what I was looking for.
He is trying to get html to create a Soundcloud widget, not get the API url for a track. The oEmbed method "will serve the widget embed code for any SoundCloud URL pointing to a user, group, set or a playlist" and is recommended to make sure Soundclouds changes don't break your app (as opposed making your own Flash object or iframe). You can call it with a PHP web request to
http://soundcloud.com/oembed?format=js&url=[escaped_url]&iframe=true
Or with a JSON-P call (using jQuery for convenience)
$.getJSON('http://soundcloud.com/oembed?callback=?',
{format: 'js', url: 'http://snd.sc/yp6VMo', iframe: true},
function(data) {
// Stick the html content returned in the object into the page
$('#your_player_div').html(data['html'])
}
)
I'm adding iframe=true so you get the new HTML5 player, omit to get the old Flash object. It also works with the .sc short urls you are using.
you can try this for song url not for the id of song url
<iframe width="100%" height="166" scrolling="no" frameborder="no"src="http://w.soundcloud.com/player/?url=http://api.soundcloud.com/elissafranceschi/war&auto_play=false&color=915f33&theme_color=00FF00"></iframe>
I'm not exactly sure what you're asking here, but it sounds like you might need the "resolve" API endpoint. http://developers.soundcloud.com/docs/api/resolve
Example:
$ curl -v 'http://api.soundcloud.com/resolve.json?url=http://soundcloud.com/matas/hobnotropic&client_id=YOUR_CLIENT_ID'
HTTP/1.1 302 Moved Temporarily
Location: http://api.soundcloud.com/tracks/49931.json
This will give you all the track information and that should be enough for whatever you need to do. Also don't forget that there's the HTML5 widget too.
I haven't tried this, modified code from here:
<object height="81" width="100%">
<param name="movie" value="http://player.soundcloud.com/player.swf?url=<?php echo $url; ?>&g=bb"></param>
<param name="allowscriptaccess" value="always"></param>
<embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=<?php echo $url; ?>&g=bb" type="application/x-shockwave-flash" width="100%"></embed>
</object>
<?php echo $url; ?>

How can I insert links into swf files using PHP?

I am trying to insert links into a swf banner(on all its surface) automatically using php. I am almost sure I saw this feature in OpenAds...
Sorry, but this can't be done apart from having a click-handler in the SWF that takes the location target of the click as a parameter, in which case the parameter is given to the Flash-file on html-level.
Eg
<object>
<param name="movie" value="YOURFLASH.swf" />
<param name="flashVars" value="clickTag=http%3A//www.example.com/&clickTAG=http%3A//www.example.com/&clicktag=http%3A//www.example.com/&clickTag2=http%3A//www.example.com/" />
<embed src="YOURFLASH.swf" flashvars="clickTag=http%3A//www.example.com/&clickTAG=http%3A//www.example.com/&clicktag=http%3A//www.example.com/&clickTag2=http%3A//www.example.com/"></embed>
</object>
The parameter name clicktag (in different case-variants) is a common parameter name for setting a click-handler in banners.
You can try to place a div over a flash clip in html and put your links there. This requires very careful positioning and may look weird.
Assuming you have access to the flash source you could load the links from a resource generated with PHP (or any server side tech) from within the flash.
Then your links are generated as xml/json/html and the flash displays them.
google flash loading data for a bunch of different tutorials and articles.

embedding audio in html - ie and firefox using php

I'm trying to create an audio captcha system for the visually impaired. I have a system that will glue several wave files together, but I'm having trouble embedding them in ie and firefox.
<script type="text/javascript">
function EvalSound(soundobj)
{
var thissound=document.getElementById(soundobj);
thissound.Play();
}
</script>
<embed src="createaudiocaptcha.php?x=46765" autostart="false" width="0" height="0" id="sound1" enablejavascript="true">
<img src="gfx/speaker.gif" border="0" alt="Audio capture for visually impaired">
using this works, however ie (vista) will just play the sound straight away, it should wait until the speaker has been clicked. IE on win xp seems to lock up for some reason.
I have tried changing the embed for this:
<object type="application/x-mplayer2" height="0" width="0" id="sound1">
<param name="src" value="createaudiocaptcha.php?x=19329">
<param name="autostart" value="0">
<param name="playcount" value="1">
</object>
however ie on winxp still sems to lock up - ie on vista plays the sound straight away and firefox will not play it saying no play() function.
does anybody know why ie on windows xp would lock up? -
Suggestion appreciated
There's an audio service that essentially does this exact thing called ReCaptcha (http://recaptcha.net/).
You can read a review of the service on ReadWriteWeb if you would like to know more about it.
Google also offers an audio captcha. There's an article on the official Google blog here.
I am doing the SAME thing as you with the SAME script. My IE begged me to install the plugin for Media Player. Once I clicked the ActiveX bar at the top if IE to install it... no more locking up. Check your Security Options in IE and/or update Java to the latest and greatest. For what it's worth... I did get mine working on IE and FF with 5 different sounds once the plugin was installed. Oh... and I put around the lines.... one in front and the /object at the end. Maybe that will help you??!?
Scriptaculos has a pretty good Sound library. You can play and stop with it; it should fulfill your needs.
Why not only embed the audio file as needed. Write the embed/object tag out with JavaScript only when someone has clicked "I need the audio captcha"
put some tags on the page like:
Please play the audio Captcha<br />
<div id="audioCaptcha">
</div>
Then the getMeTheAudio() function fills in the innerHTML of the audioCaptcha div with the embed/object. You could sniff the browser type if you want to be fancy.
You will find multiple possible options in the link below ,
http://www.phon.ucl.ac.uk/home/mark/audio/play.htm#

Categories