IonDen / ion.sound

JavaScript plugin for playing sounds and music in browsers

Home Page:http://ionden.com/a/plugins/ion.sound/en.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Play sound after AJAX success fails on iOS

m0mo0815 opened this issue · comments

Hi,

I do not know if this is a problem or my skills with javascript, but I have the following problem:

I use the jQuery form validator (http://www.formvalidator.net/) with a AJAX request to save the inserted values. If this was successful, a sound should be played.

This works fine on desktop (firefox, safari, ect., at least on MacOS), however, not on iOS (tested with iOS9/iOS10)

Is there a misstake in implementation or am I up to somthing? ;)

I am happy for any hint for resolving the issue. Thanks!
Stephan


This is my code:

` // init bunch of sounds
ion.sound({
sounds: [
{name: "sound"}
],

	    // main config
	    path: "sounds/",
	    preload: true,
	    multiplay: true,
	    volume: 1
	});
	
	$("form.registration-form").submit(function(e) {
		e.preventDefault();
	});	

	$.validate({
		validateOnBlur : false,
		onError : function() {
			...
		},
	    onSuccess : function() {
			$.ajax({
			    url:...,
				type:...,
			    data:...,
			    success:function(response) {
					ion.sound.play("sound");
					...
			    }
			})
		}
	});`

Hi, on iPhone and other Apple mobile devices where is a restriction. Sounds can be played only by direct user action at first, and only then it can be played by script (they will not even load, until user press some button)

Hello IonDen,

thanks for your feedback and sorry that I missed that in the description.

Regards
Stephan

Np. Hope in next few years apple will remove this restriction.