Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15618] Titanium.Media.VideoPlayer fires COMPLETE event when url changes

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelscomplete, events, reprod, url, video, videoplayer
ReporterEzoom Agency
AssigneeUnknown
Created2013-09-26T20:27:20.000+0000
Updated2018-02-28T20:04:19.000+0000

Description

After changing the Titanium.Media.VideoPlayer.url value the videoPlayer fires a onComplete event that should not be fired, or at least fired including the real reason for it, but currently the event.reason is 0 (Ti.Media.VIDEO_FINISH_REASON_PLAYBACK_ENDED). This is causing a lot of trouble to create a playlist app. We could have a VIDEO_FINISH_REASON_SOURCE_CHANGED as a new reason, would be way better This is a very old topic: [http://developer.appcelerator.com/question/121674/complete-event-firing-when-changing-url-on-video-player]
var win1 = Titanium.UI.createWindow({  
    title:'Tab 1',
    backgroundColor:'#fff',
 
});

var videoPlayer = Ti.Media.createVideoPlayer({
	backgroundColor:'#fff',	
	autoplay:true,
	url:'firstSong.mp3'
})

videoPlayer.addEventListener('complete',function(e){
	Ti.API.info('========')
	Ti.API.info('complete event fired - ' + JSON.stringify(e))
	Ti.API.info('Event reason should not be 0 but it is ' + e.reason)
	Ti.API.info('========')	
})

var nextSongBtn = Ti.UI.createButton({
	top:100,
	title:'Click to change the music' 
})
nextSongBtn.addEventListener('click',function(){
	videoPlayer.url = 'mynewfile.mp3';	
})
 

win1.add(videoPlayer);
win1.add(nextSongBtn);

win1.open();

//Current playback reasons, here we could have a VIDEO_FINISH_REASON_SOURCE_CHANGED as a new reason
Ti.API.info('Ti.Media.VIDEO_FINISH_REASON_PLAYBACK_ENDED = ' + Ti.Media.VIDEO_FINISH_REASON_PLAYBACK_ENDED)
Ti.API.info('Ti.Media.VIDEO_FINISH_REASON_PLAYBACK_ERROR = ' + Ti.Media.VIDEO_FINISH_REASON_PLAYBACK_ERROR)
Ti.API.info('Ti.Media.VIDEO_FINISH_REASON_USER_EXITED = ' + Ti.Media.VIDEO_FINISH_REASON_USER_EXITED)

Comments

  1. Shameer Jan 2014-08-20

    Issue reproduces on both SDK version 3.1.3 and 3.4.0 (Unreleased) Titanium Command-Line Interface, CLI version 3.3.0, Titanium SDK version 3.4.0.GA Titanium SDK version 3.1.3 GA iOS SDK: 7.1 iOS iPhone: 7.1
  2. 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