cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "dw1 (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CB-11369) Media Plugin: Ignore ANDROID_LOOP exif header
Date Fri, 03 Jun 2016 09:12:59 GMT

     [ https://issues.apache.org/jira/browse/CB-11369?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

dw1 updated CB-11369:
---------------------
    Description: 
Any sound file that has an ANDROID_LOOP=true exif header, such as many of the /system/media/audio
files included with Lollipop, will always loop forever even if only expected to play once
via the media plugin. This can lead to having to shut down an app to stop the sound. The plugin
should ignore the header and play the sound once unless using the plugin loop feature, as
expected.

My workaround: http://pastebin.com/raw/Q9kCriab

  was:
Any sound file that has an ANDROID_LOOP=true exif header, such as many of the /system/media/audio
files included with Lollipop, will always loop forever even if only expected to play once
via the media plugin. This can lead to having to shut down an app to stop the sound. The plugin
should ignore the header and play the sound once unless using the plugin loop feature, as
expected.

My workaround in an app that allows choosing of system sounds that may or may not have ANDROID_LOOP=true
set involves checking the file and making a note as follows:

			window.resolveLocalFileSystemURL($('#soundfile').val(), function(entry){
				console.log('got file entry=',entry);
				entry.file(function(file){
					var reader = new FileReader(); 
					reader.onload = function(e) {
						this.result = this.result.substr(0,1024);
						if(this.result.toLowerCase().indexOf("android_loop=true")>0){
							console.log("ANDROID_LOOP=true detected!");
							settings.alarm_looper=true;
						} else if(settings.hasOwnProperty('alarm_looper')) delete settings.alarm_looper;
						// async, so..
						play_sound($('#soundfile').val());
						localStorage.setItem('settings',JSON.stringify(settings));
					}
					reader.readAsText(file);
				});
			}, function(e){
				console.log('failed to get file e=',e);
				if(settings.hasOwnProperty('alarm_looper')) delete settings.alarm_looper;
			});

Then I use a setInterval that detects duration to play the sound:

	sound_start=new Date().getTime();
	media1.play({ numberOfLoops: 1 });
	// hack for bug where files with ANDROID_LOOP=true always loop
	if(settings.alarm_looper){
		sound_end=null;
		if(!handle.hasOwnProperty('media')) handle.media=setInterval(function(){
			// wait until media gives us the duration..
			if(media1._duration==-1){
				console.log('media1._duration=-1, interval return');
				return;
			} else if(sound_end===null) sound_end=Math.round(sound_start+(media1._duration*1000)-40);
			
			var now=new Date().getTime();
			if(now>=sound_end){
				console.log('now>=sound_end '+now+'>='+sound_end+' killing media');
				if(media1!=null) media1.release();
				if(handle.hasOwnProperty('media')){
					clearInterval(handle.media);
					delete handle.media;
				}
				sound_end=null;
			}
		}, 50);
	}


> Media Plugin: Ignore ANDROID_LOOP exif header
> ---------------------------------------------
>
>                 Key: CB-11369
>                 URL: https://issues.apache.org/jira/browse/CB-11369
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, Plugin Media
>            Reporter: dw1
>
> Any sound file that has an ANDROID_LOOP=true exif header, such as many of the /system/media/audio
files included with Lollipop, will always loop forever even if only expected to play once
via the media plugin. This can lead to having to shut down an app to stop the sound. The plugin
should ignore the header and play the sound once unless using the plugin loop feature, as
expected.
> My workaround: http://pastebin.com/raw/Q9kCriab



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message