Use flash var grabbed by another function JS - javascript

so this is what I need to do. So this function is called when the Flash video recorder on the page saves the video:
function onSaveOk(streamName,streamDuration,userId,cameraName,micName,recorderId){
//alert("onSaveOk("+streamName+","+streamDuration+","+userId+","+cameraName+","+micName+")");
//the user pressed the [save] button inside the recorder and the save_video_to_db.XXX script returned save=ok
//recorderId: the recorderId sent via flash vars, to be used when there are many recorders on the same web page
$('#record').hide();
$('#jwplayer').show();
}
I then have my JWplayer script that I would like to use the streamName flash var. Here is my JWPlayer script with my current attempt:
<div id="jwplayer">
<center>
<div id='mediaplayer'></div>
<script type="text/javascript">
jwplayer('mediaplayer').setup({
'flashplayer': 'jwplayer/player.swf',
'id': 'playerID',
'width': '640',
'height': '580',
'provider': 'rtmp',
'streamer': 'rtmp://domain/recorder/_definst_',
'file': 'onSaveOk("+streamName+")'
});
</script>
</center>
This is where I try to use the flash var,
'file': 'onSaveOk("+streamName+")'
As it is like that, it does not work, could someone show me the correct way to do this? Thanks.

This site makes understanding and implementing a flash var as no-brainer as it gets.
Copy and paste code:
http://www.justthecodeplease.com/category/urls-flashvars/

Related

including a javascript file in a JS file without using <script>

I have a piece of JS which more or less looks like this
<script type="text/javascript" src="http://player.script.com/jsapi">
player = new playrer.Player('Yplayer',{
styleid: '0',
client_id: 'YOUR YOUKUOPENAPI CLIENT_ID',
vid: 'Replace the Youku Video ID'
});
</script>
Which would work if I directly drop it into my html document via script tag. But I am trying to call this by including a separate global javascript file. Can I avoid including the remote .jsapi via the <script>
a solution will be using jquery getScript() function
$.getScript( "http://player.script.com/jsapi", function( data, textStatus, jqxhr ) {
player = new playrer.Player('Yplayer',{
styleid: '0',
client_id: 'YOUR YOUKUOPENAPI CLIENT_ID',
vid: 'Replace the Youku Video ID'
});
});
You shouldn't use both the src attribute and javascript code (body content) inside the same tag.
As others have commented, the "jsapi" script will execute, but ignore your local javaScript. You need:
<script type="text/javascript" src="http://player.script.com/jsapi"></script>
<script type="text/javascript">
player = new playrer.Player('Yplayer',{
styleid: '0',
client_id: 'YOUR YOUKUOPENAPI CLIENT_ID',
vid: 'Replace the Youku Video ID'
});
</script>
You can put the embedded script in another file if you wish

Setup hangout button in my website

I have strange problem. I'm trying to integrate hangout button in my website to enable user to open the lecture directly from the website and I used the sample code in Google Hangout API Documentation
https://developers.google.com/+/hangouts/button#hangout_button_code
button it didn't work, so what is the problem ?
<script src="https://apis.google.com/js/platform.js" async defer> </script>
<div id="placeholder-div3"></div>
<script>
gapi.hangout.render('placeholder-div3', {
'render': 'createhangout',
'hangout_type': 'onair',
'initial_apps': [{'app_id' : '184219133185', 'start_data' : 'dQw4w9WgXcQ', 'app_type' : 'ROOM_APP' }],
'widget_size': 175
});
</script>
I'm thinking your problem has to do with the fact that you are deferring your library script, but not gapi.hangout.render script. So, my guess is your gapi.hangout.render code is running before the library it utilizes ever gets to load.
Try just removing the async and defer attributes and see if that works for you.
The async I would imagine might also cause problems if your render method is getting called before the library loads fully.
To follow-up, I looked at the gapi.hangout.render method and it's not clear about the first parameter, but disregard my previous answer and try this:
<script>
gapi.hangout.render(document.querySelector('#placeholder-div3'), {
'render': 'createhangout',
'hangout_type': 'onair',
'initial_apps': [{'app_id' : '184219133185', 'start_data' : 'dQw4w9WgXcQ', 'app_type' : 'ROOM_APP' }],
'widget_size': 175
});
</script>

iFrame URL parameter to an in Wordpress?

I have a page which has an iframe embed of an external page. I want to find zip code
Here is my iframe:
<iframe src="http://mortgagerates.icanbuy.com/?zip=" width="1020" height="1200">
http://mortgagerates.icanbuy.com/?zip=10458 (Main Site )
But i want i frame and my browser url same below:
http://www.mysite.com/?zip=10458 (I want something like that)
Is this possible in wordpress? how?
Please check it.. I hope work it...
<iframe src="http://mortgagerates.icanbuy.com/?zip" width="1020" height="1200" class="iframe-wrapper">
And add this jQuery. Thats It!
<script type="text/javascript">
$(function() {
var search = window.location.search;
search = search.replace("?","&");
$(".iframe-wrapper").attr("src", $(".iframe-wrapper").attr("src")+search);
});
</script>
This is ajax page. you want to use ajax.
http://mortgagerates.icanbuy.com/ajax/rates-search?callback=jQuery17209362620610679678_1385958692723&source=1&results_count=0&period=PERIOD_FIXED_30YEARS&state=33&property_type=34&occupancy=49&fico=740&points=1.5&currently_working=Yes&property_interested=Yes&show_fha=0&cashout=0&city=10458&valoans=0&militaryaff=1&hadvabefore=0&rate_lock=99&loan=200000&transaction=54&ltv=80&cltv=80&DO_UPDATE_WRITE=0&id=d4ea9f8db0477778&external=0&_=1385958692873
you need to pass your zipcode into city=10458. its return json encoded format. you simply parse this into your design.

Youtube JS API Causes Error in Internet Explorer

I am attempting to embed a Youtube Video inside a webpage. I am using the Youtube Javascript API to embed/load the videos.
My Problem: The video embeds inside Internet Explorer but there are many javascript errors when I inspect the console. These errors mean I cannot replay the video, make the video grow, or really do anything. These javascript errors do not occur in Firefox or Chrome just IE.
Console Error:
SCRIPT87: Invalid Argument.
www-embed-player-vf1m....js line 211 character 405
Heres my JSFiddle that demonstrates the problem. Remember to RUN it in IE to see the problem.
My code:
<html>
<head>
<script src="https://www.youtube.com/player_api" type="text/javascript"></script>
<script type="text/javascript">
function loadYouTubeVideo(uid) {
setTimeout( function() {
var id = uid;
var instPlayer = new YT.Player(id, {
height: '240',
width: '426',
enablejsapi: 1,
suggestedQuality: 'highres',
videoId: uid});
}, 500);
}
</script>
</head>
<body>
<p>Run in IE and look at console</p>
<div id="Go3u2zw6fbE"></div><script> loadYouTubeVideo("Go3u2zw6fbE"); </script>
</body>
<html>
The problem was that I was running the Javascript code from a local HTML file and not from a HTML file over the internet.
I guess when you run the Youtube Javascript API in a local HTML file (inside Internet Explorer only) the youtube video wont play. Even if I click 'Allow Javascript' it still wont play.

jwplayer streaming m3u from another domain

Looking to stream a radio station on my website, we also host the streaming but from a different domain.
Just getting this error:
Task Queue failed at step 5: Playlist could not be loaded due to crossdomain policy restrictions
Code on domain A:
<div id="mediaplayer">Loading...</div>
<script type="text/javascript" src="/jwplayer/jwplayer.js"></script>
<script type="text/javascript">
jwplayer("mediaplayer").setup({
flashplayer: "/jwplayer/player.swf",
playlistfile: "http://domainB/stream.m3u",
image: "/images/listening.jpg",
type: "sound",
allowscriptaccess:"always",
width:300,
height:300
});
</script>
Just having no luck, tried a variety of options...
Am I wasting my time with out crossdomain.xml on domain B ? (of which I have no access to at the moment, but maybe able to get access to soon)
The stream works fine from itunes, winamp etc..
Okay, the problem was:
The url for the m3u file isn't the actual url for the stream.
I needed to open the m3u file in a text editor, and use that url, which included port etc.
<script type='text/javascript' src='/jwplayer/jwplayer.js'></script>
<div id='media'></div>
<script type='text/javascript'>
jwplayer('media').setup({
'flashplayer': '/jwplayer/player.swf',
'file': 'http://xx.xxxxxx.xxx:80/xxxxfm',
'provider': 'sound',
'controlbar': 'bottom',
'image': "/images/listening.jpg",
'width': '300',
'height': '300'
});
</script>
this code seems to work, no crossdomain.xml needed, it was requesting one only because the url was incorrect.

Categories

Resources