Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3348] Ti.Media.Sound url bug

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionWon't Fix
Resolution Date2011-08-29T14:13:49.000+0000
Affected Version/sn/a
Fix Version/sSprint 2011-35
ComponentsiOS
Labelscreatesound, media, sound
Reporternetspy
AssigneeReggie Seagraves
Created2011-04-15T03:42:43.000+0000
Updated2017-03-22T18:04:29.000+0000

Description

This works:

var sound = Titanium.Media.createSound();
sound.url='../cricket.wav';
sound.play();

But if I try to change the url after that, sound plays still the cricket.wav sound.

sound.url='../other_sound.wav';
sound.play(); /* plays cricket.wav */

Comments

  1. Eduardo Gomez 2011-08-18

    Associated HD ticket

    ENT customer relying on this, APP-117136

    Tested on

    Simulator iOS 4.3 Device iPod / iPad 1

    Target Environment

    {noformat} Product: Mobile SDK: 1.7.2 Platform OS: iOS Version: 4.3 {noformat}

    Repro sequence

       //
       // create controls tab and root window
       //
       var win2 = Titanium.UI.createWindow({
       	title : 'Tab 2',
       	backgroundColor : '#fff'
       });
       var tab2 = Titanium.UI.createTab({
       	icon : 'KS_nav_ui.png',
       	title : 'Tab 2',
       	window : win2
       });
       
       var label2 = Titanium.UI.createLabel({
       	color : '#999',
       	text : 'I am Window 2',
       	font : {
       		fontSize : 20,
       		fontFamily : 'Helvetica Neue'
       	},
       	textAlign : 'center',
       	width : 'auto'
       });
       
       win2.add(label2);
       
       var b1 = Titanium.UI.createButton({
       	title:'Play me!',
       	color : '#fff',
       	top : 74,
       	left : 0,
       	width : 107,
       	height : 69
       });
       
       win2.add(b1);
       
       win2.open();
       
       var snd = Titanium.Media.createSound({
       	//url : 'mp3/sn-1.mp3',
       	preload : true
       });
       snd.isLopping = false;
       
       var type = 1;
       
       function go() {
       	
       	try {
       		if(type == 1) {
       			sn = 'mp3/sn-1.mp3';
       			type = 2;
       			Ti.API.info("first file");
       		}else if(type == 2) {
       			sn = 'mp3/sn-9.mp3';
       			type = 1;
       			Ti.API.info("second file");
       		}
       
       		snd.url = sn;
       		Ti.API.info(sn);
       		
       	} catch (e) {
       		Ti.API.error("FAIL: play creating sound:" + e);
       	}
       	
       	snd.play();
       }
       
       b1.addEventListener('click', function(e) {
       	Ti.API.info("click");
       	go();
       }, false);
       
  2. Reggie Seagraves 2011-08-29

    Duplicate of customer issue TIMOB-1488. This can be easily achieved by creating a new sound object. Furthermore, this would create a platform parity issue and would complicate any future API that, for example, would support sound channels, etc. A sound object should be considered an immutable object once it's constructed.
  3. Esben Maaløe 2012-08-07

    MY COMMENT PERTAINS TO ANDROID ONLY, HAVE NOT TESTED ON iOS. MAY OR MAY NOT APPLY TO iOS AS WELL But if you do that (create a new soundobject) - you end up depleting resources and your application will go silent. You will get an errormessage in the log-output, but no errors are raised to the app. Further details here: http://developer.appcelerator.com/question/140287/problems-with-timediasound-on-android
  4. Esben Maaløe 2012-08-07

    Besides - the docs have no mention of not being able to set a new Url, on the contrary, in the docs you have a 'setUrl' method. This method is not available on Android. So a doc-update is needed
  5. Lee Morris 2017-03-22

    Closing ticket as the issue will not fix and with reference to the above comments.

JSON Source