Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9477] iOS: Media - Incorrect state is being displayed when media streaming is stopped.

GitHub Issuen/a
TypeBug
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 2.1.0, Release 3.1.0
Fix Version/sn/a
ComponentsiOS
Labelsapi, qe-ios060112, reprod
ReporterAnshu Mittal
AssigneeUnknown
Created2012-06-11T05:00:41.000+0000
Updated2018-02-28T20:04:07.000+0000

Description

Media displays the state as Initialized(0) instead of Stopped(5) when streaming is stopped. This is not regression. The issue occurs as far as 1.8.2. Steps to reproduce: 1. Create app with the code below. 2. Launch the app. 3. Start streaming. 4. Stop streaming. Actual: The state displayed on the screen is initialized(0) when the streaming is stopped. whereas the console displays the state stopped before displaying the state initialized. On Android, this works fine and the state is shown as stopped. Expected: The correct state should be displayed on the screen as well as console.


var win = Titanium.UI.createWindow({  
    title:'Tab 1',
    backgroundColor:'#fff'
});

		var debug = Ti.API.debug;
		var info = Ti.API.info;
		
		Ti.Media.audioSessionMode = Ti.Media.AUDIO_SESSION_MODE_PLAYBACK;
		
		var url = Titanium.UI.createTextField({
		    value: 'http://www.parishiltonjustme.com/downloads/audio/08_Screwed.mp3',
		    color: '#336699',
		    returnKeyType: Titanium.UI.RETURNKEY_GO,
		    keyboardType: Titanium.UI.KEYBOARD_URL,
		    hintText: 'url',
		    textAlign: 'left',
		    clearOnEdit: true,
		    height: 35,
		    top: 10,
		    width: 300,
		    borderStyle: Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
		});
		
		var streamButton = Titanium.UI.createButton({
		    title: 'Start Streaming',
		    top: 60,
		    width: 200,
		    height: 40
		});
		
		var pauseButton = Titanium.UI.createButton({
		    title: 'Pause Streaming',
		    top: 110,
		    width: 200,
		    height: 40,
		    enabled: false
		});
		
		var progressLabel = Titanium.UI.createLabel({
		    text: 'Time Played: Not Started',
		    top: 160,
		    left: 10,
		    height: 40,
		    width: 300,
		    color: '#555',
		    textAlignment: 'center'
		});
		
		var stateLabel = Titanium.UI.createLabel({
		    text: 'State: Not Started',
		    top: 180,
		    left: 10,
		    width: 300,
		    height: 40,
		    color: '#555'
		});
		
		win.add(url);
		win.add(streamButton);
		win.add(pauseButton);
		win.add(progressLabel);
		win.add(stateLabel);
		
		var streamer = Ti.Media.createAudioPlayer();
		
		streamButton.addEventListener('click', function() {
		    if (streamButton.title == 'Stop Stream') {
		        progressLabel.text = 'Stopped';
		        streamer.stop();
		        pauseButton.enabled = false;
		        pauseButton.title = 'Pause Streaming';
		        streamButton.title = "Start Streaming";
		    }
		    else {
		        progressLabel.text = 'Starting ...';
		        streamer.url = url.value;
		        streamer.start();
		        pauseButton.enabled = true;
		        pauseButton.title = 'Pause Streaming';
		        streamButton.title = "Stop Stream";
		    }
		});
		
		pauseButton.addEventListener('click', function() {
		    streamer.pause();
		    if (streamer.paused) {
		        pauseButton.title = 'Unpause Streaming';
		    }
		    else {
		        pauseButton.title = 'Pause Streaming';
		    }
		});
		
		streamer.addEventListener('change', function(e) {
		    stateLabel.text = 'State: '+e.description +' ('+e.state+')';
		    Ti.API.info('disc: ' + e.description);
		    Ti.API.info('state: ' + e.state);
		});
		
		streamer.addEventListener('progress', function(e) {
		    progressLabel.text = 'Time Played: ' + Math.round(e.progress) + ' seconds';
		});
		
		// save off current idle timer state
		var idleTimer = Ti.App.idleTimerDisabled;
		
		// while we're in this window don't let the app shutdown
		// when the screen is idle
		Ti.App.idleTimerDisabled = true;
		
		win.addEventListener('close', function() {
		    Ti.API.info("window was closed, idleTimer reset to = " + idleTimer);
		    
		    // restore previous idle state when closed
		    Ti.App.idleTimerDisabled = idleTimer;
		});

win.open();

Comments

  1. Anshu Mittal 2012-06-19

    This issue also occurs for iPhone 3GS(v 5.0.1)
  2. Shameer Jan 2013-04-12

    Issue reproduces Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 Titanium SDK version: 3.0.2 iOS iPhone Simulator: iOS SDK version: 6.0
  3. Lee Morris 2017-06-22

    I am able to reproduce this issue with the following environment; iPhone 7 (10.2) Studio 4.9.0.201705302345 Ti SDK 6.1.1.v20170620103414 Appc NPM 4.2.9 Appc CLI 6.2.1 Ti CLI 5.0.13 Alloy 1.9.11 Arrow 2.0.0 Xcode 8.2 (8C38) Node v4.8.2 Java 1.8.0_131

JSON Source