On my PC I get a sound in chrome browser when I send a message via my smart phone (android) But on my phone I don't get a sound. I tested this with 2 laptops and it works now with those but my phone's browser does not give a beep. The goal is that I get a sound when I receive a message. The strange thing is that my phone gives a sound when I use the standard meteor example app. I mean when you create your app with meteor create you get a skeleton code and I inserted "new Audio('path to sound file').play(); into the click event. It works perfectly!
But in my app it only works sometimes and never on my mobile. I use the same audio file and have it in my public folder of the meteor app.
var msgId=0;
var old=Session.get('msgCount');
Template.berichtenlijst.messages=function(){
if(old<Session.get('msgCount')){//there is a new message in Message collection
old=Session.get('msgCount');
var array=Messages.find().fetch();
if(array.length>0&&(msgId!==array[array.length-1]._id)){
//notify new message
new Audio('audio.mp3').play();
}
}
return Messages.find({}, { sort: { timestamp: -1 },limit:100});
}
msgId has a value, the id is from Messages.insert(..) I have debugged that and that is right. Also the SESSION variable is the right one. And with the example app I get the sound also on mobile. I have no idea what is going on. Sorry I know it might be a vague question but it is a vague problem to me.