SoundManager2 doesn't play on android - soundmanager2

I have implemented in a page to play a sound if some criteria are fired inside a polling cycle of 3 seconds as you can see here:
$(document).ready(function () {
soundManager.setup({
url: '/js/soundmanager2.swf',
debugMode: true
});
});
function playMe() {
soundManager.createSound({
url: '/images/woop_woop.mp3',
onload: function() {
console.log('start playing...');
soundManager._writeDebug(this.id + ' loaded');
this.play();
}
}).load();
}
function NewReadyData()
(
.
.
.
.
.
jQuery.ajax({
type: "GET",
dataType: "json",
url: "./getData.php?xxxxxxxxxxxx",
success: function(data) {
if (data.length > 0) {
if (sound_notify) {
executeAsync(function() {
playMe();
});
}
if ( window.navigator && window.navigator.vibrate && buzz_notify )
window.navigator.vibrate(2000);
}
}
});
.
.
.
.
setTimeout('NewReadyData', 3000);
}
setTimeout('NewReadyData', 3000);
The matter is on Window Desktop it works and it plays that little mp3 but on Android it doesn't play sound. Is there a way to force playing? like calling an ajax so it would play like in independent event of playing when occurs?...
Thanks
Cheers,
Luigi

Nevermind, I figured out myself the solution...
I thought I couldn't use tag but after discovering to enable that flag about requisite for multimedia reproduction so now I could play by code.
Thanks everyone anyway! :)
Cheers
Luigi

Related

Getting an ' instance.requestPaymentMethod is not a function' in Braintree's sample

I'm getting an instance.requestpaymentmethod is not a function when I was just following along the tutorial for custom-field integration found here:
https://developers.braintreepayments.com/start/tutorial-hosted-fields-node
The error happens when I click on the "Pay" button.
Did anyone solve this problem? My assumption is that the code isn't updated or the script sources changed somewhat. If anyone from Braintree can actually help, that'll be great.
Thanks!
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.
I took a look at the example code snippet in the guide you shared and I was able to find the culprit. First off, the error you're getting is expected as the requestPaymentMethod method actually belongs to our Drop-In UI solution and the Hosted Fields JS library doesn't have such module. I informed our Documentation team to get that code example updated.
That being said, you can find a working example in our Hosted Fields guide. If you check the function (hostedFieldsErr, hostedFieldsInstance) callback function, you'll see that the payment nonce is created by the tokenize function of the hostedFieldsInstance.
I also ran into this issue today. Use the following code in <script> tag. It will work for you.
var form = document.querySelector('#hosted-fields-form');
var submit = document.querySelector('input[type="submit"]');
braintree.client.create({
authorization: '<YOUR_TOKENIZATION_KEY>'
}, function (clientErr, clientInstance) {
if (clientErr) {
console.error(clientErr);
return;
}
braintree.hostedFields.create({
client: clientInstance,
styles: {
'input': {
'font-size': '14px'
},
'input.invalid': {
'color': 'red'
},
'input.valid': {
'color': 'green'
}
},
fields: {
number: {
selector: '#card-number',
placeholder: '4111 1111 1111 1111'
},
cvv: {
selector: '#cvv',
placeholder: '123'
},
expirationDate: {
selector: '#expiration-date',
placeholder: '10/2019'
}
}
}, function (hostedFieldsErr, hostedFieldsInstance) {
if (hostedFieldsErr) {
console.error(hostedFieldsErr);
return;
}
form.addEventListener('submit', function (event) {
event.preventDefault();
hostedFieldsInstance.tokenize(function (tokenizeErr, payload) {
if (tokenizeErr) {
console.error(tokenizeErr);
return;
}
console.log('Got a nonce: ' + payload.nonce);
$.ajax({
type: 'POST',
url: '<YOUR_API_URL>',
data: { 'paymentMethodNonce': payload.nonce }
}).done(function (result) {
hostedFieldsInstance.teardown(function (teardownErr) {
if (teardownErr) {
console.error('Could not tear down Drop-in UI!');
} else {
console.info('Drop-in UI has been torn down!');
$('#submit-button').remove();
}
});
if (result.success) {
$('#checkout-message').html('<h1>Success</h1><p>Your Drop-in UI is working! Check your sandbox Control Panel for your test transactions.</p><p>Refresh to try another transaction.</p>');
} else {
console.log(result);
$('#checkout-message').html('<h1>Error</h1><p>Check your console.</p>');
}
});
});
}, false);
});
});

Is it possible to configure Featherlight popups to show only once per user?

Looking to configure featherlight.js to show only once per user (ie. if user loads the page again they will not see it). With thanks, Cas.
Colleague found a solution...
welcomeLightbox: function () {
'use strict';
if ($.cookie('welcomeLightboxShown') == null) {
$.featherlight($('#mylightbox'), {});
}
$('.featherlight-close').click(function() {
// $.cookie('welcomeLightboxShown', 'true', { path: '/' });
$.cookie('welcomeLightboxShown', 'true', { expires: 365, path: '/' });
});
},

cordova background geolocation plugin on reboot

I am building an ionic app with background geolocation plugin https://github.com/mauron85/cordova-plugin-background-geolocation.
I want to make an app to send its location after reboot. The plugin I am using seems to have the option, but it is not working properly. An app only sends its location to the server only after execute an app at least once after every boot.
Any help or suggestion would be appreciated. Thank you in advance!
My code is below
Configuration
backgroundGeolocation.configure(callbackFn, failureFn, {
locationProvider: backgroundGeolocation.provider.ANDROID_ACTIVITY_PROVIDER,
desiredAccuracy: 10,
stationaryRadius: 10,
distanceFilter: 10,
interval: 60000,
maxLocations: 50,
startOnBoot: true, // from my understanding, this should make an app track its location even after reboot
stopOnTerminate: false
});
Callback Function
var callbackFn = function(location) {
console.log('[js] BackgroundGeolocation callback: ' + location.latitude + ',' + location.longitude);
// Do your HTTP request here to POST location to your server.
var link = API_URL;
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";
$http({
method: 'POST',
url: link,
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
transformRequest: function(obj) {
var str = [];
for(var p in obj)
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
return str.join("&");
},
params: {
'device': 'android',
},
data: {
lat:location.latitude,
lng:location.longitude,
}
}).success(function(data){
console.log(data);
}).error(function(data){
console.log(data);
});
backgroundGeolocation.finish();
};
i hope you would have found your answer by now, posting this might help others too.
don't expect your callback to be executed after the reboot, as the activity might be killed, instead use url option of the plugin to continue sending your location updates to the server.

How to post Flash applets to a wall on Facebook?

In the comments of this question, users have commented that it's possible to insert a Flash applet into a Facebook wall post. I was under the impression this isn't possible without making a FB app.
I'm aware that FB will convert links to various media types - e.g. a link to a MP3 becomes automagically a SWF MP3 player, but the Flash applet used is chosen by FB's internal logic, not by the content of the post. Is it possible to embed a SWF applet of your own choosing?
As I haven't been able to find any documentation on this, has anyone else? Or, do you have some PoC code that does this?
you can use the Facebook's JS-SDK for it:
FB.ui(
{
method: 'feed',
name: 'Title pf post',
link: 'http://link.to.target',
picture: 'http://link.to.previewimage',
source: 'http://link.to.swf',
caption: 'Subtitle',
description: 'Maintext',
},
function(response) {
if (response && response.post_id) {
//alert('Post was published.');
} else {
//alert('Post was not published.');
}
}
);
As you said in the comment of the other question, that you were also interested in how to pass parameters to the swf, here is the solution:
in javascript
function postOnWall(fbuid) {
var params = {};
params['message'] = "my message";
params['name'] = "my name";
params['description'] = "my description";
params['link'] = "https://www.mylink.com";
params['caption'] = "my caption";
params['picture'] = "https://www.mylink.de/thumb.png";
params['source'] = "https://www.mylink.de/Main.swf" + "?bla=thisisyourdynamicquerystring";
FB.api('/' + fbuid + '/feed', 'post', params, function(response) {
if (!response || response.error) {
// Error occured while publishing to stream
} else {
// Published to stream
}
});
}
in actionscript
public function Main() {
this.loaderInfo.addEventListener(Event.COMPLETE, loaderComplete);
}
private function loaderComplete(event : Event) : void {
var myQueryStrings : Object = this.loaderInfo.parameters;
if (myQueryStrings && myQueryStrings.bla) {
_myMovie.label.text = myQueryStrings.bla;
}
}

Sencha Touch and Facebook button

I need to create a button to submit a comment on Face Book wall.
I am using MVC in Sencha touch and in my controller I use a function as
facebookComment: function()
{
--------
}
This function is to be called when a button is pressed.
Can any body please throw some light on how to go about this?
i am using following code to post on friends wall see if it is useful to you or not
var postParams = {
method: 'stream.publish'
, target_id: friend_id
, display: 'popup'
, message: message
, user_message_prompt: "Post message!"
}
FB.api(postParams, function(response) {
if(response.error_code || !response) {
to handle error
}
});
or refer this link https://developers.facebook.com/docs/reference/rest/stream.publish/
Well, first you should already be using the Javascript SDK. Then just issue a HTTP POST request to the feed connection of the current user using the FB.api() method with the message field set to your comment:
var body = comment_var;
FB.api('/me/feed', 'post', { message: body }, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
});
Obviously, should be taking care of the user login status (maybe using the method FB.getLoginStatus()).