[TIMOB-25640] iOS: Ti.Media.VideoPlayer "playbackState" constants are undefined
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-01-17T09:21:18.000+0000 |
Affected Version/s | Release 7.0.0 |
Fix Version/s | Release 7.0.2 |
Components | iOS |
Labels | ios, videoplayer |
Reporter | Mostafizur Rahman |
Assignee | Hans Knöchel |
Created | 2018-01-02T17:54:33.000+0000 |
Updated | 2018-02-05T15:20:18.000+0000 |
Description
Hello,
In iOS on SDK 7.0.0+, the playbackState constants are
*undefined*
(http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Media.VideoPlayer-property-playbackState).
- Ti.Media.VIDEO_PLAYBACK_STATE_INTERRUPTED
- Ti.Media.VIDEO_PLAYBACK_STATE_PAUSED
- Ti.Media.VIDEO_PLAYBACK_STATE_PLAYING
- Ti.Media.VIDEO_PLAYBACK_STATE_SEEKING_BACKWARD
- Ti.Media.VIDEO_PLAYBACK_STATE_SEEKING_FORWARD
- Ti.Media.VIDEO_PLAYBACK_STATE_STOPPED
*Testing Environment:*
Appcelerator Command-Line Interface, version 7.0.1
SDK: 7.0.1.GA
iOS simulator: iPhone 7
*Test Code:*
var vidWin = Titanium.UI.createWindow({
title : 'Video View Demo',
backgroundColor : '#fff'
});
var videoPlayer = Titanium.Media.createVideoPlayer({
top : 2,
autoplay : true,
backgroundColor : 'blue',
height : 300,
width : 300,
mediaControlStyle : Titanium.Media.VIDEO_CONTROL_DEFAULT,
scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FIT
});
// Log raw-values of constants
Ti.API.info('Titanium.Media.VIDEO_PLAYBACK_STATE_INTERRUPTED ' + Titanium.Media.VIDEO_PLAYBACK_STATE_INTERRUPTED);
Ti.API.info('Titanium.Media.VIDEO_PLAYBACK_STATE_PLAYING ' + Titanium.Media.VIDEO_PLAYBACK_STATE_PLAYING);
Ti.API.info('Titanium.Media.VIDEO_PLAYBACK_STATE_STOPPED ' + Titanium.Media.VIDEO_PLAYBACK_STATE_STOPPED);
videoPlayer.url = 'video.mp4';
vidWin.add(videoPlayer);
videoPlayer.addEventListener('playbackstate', function() {
var message = 'Unknown';
switch (videoPlayer.playbackState) {
case Ti.Media.VIDEO_PLAYBACK_STATE_INTERRUPTED:
message = 'Interrupted';
break;
case Ti.Media.VIDEO_PLAYBACK_STATE_PLAYING:
message = 'Playing';
break;
case Ti.Media.VIDEO_PLAYBACK_STATE_PAUSED:
message = 'Paused';
break;
case Ti.Media.VIDEO_PLAYBACK_STATE_STOPPED:
message = 'Stopped';
}
Ti.API.info(message);
});
vidWin.open();
*Test Results:*
[INFO] : Titanium.Media.VIDEO_PLAYBACK_STATE_INTERRUPTED undefined
[INFO] : Titanium.Media.VIDEO_PLAYBACK_STATE_PLAYING undefined
[INFO] : Titanium.Media.VIDEO_PLAYBACK_STATE_SEEKING_BACKWARD undefined
[INFO] : Titanium.Media.VIDEO_PLAYBACK_STATE_SEEKING_FORWARD undefined
[INFO] : Titanium.Media.VIDEO_PLAYBACK_STATE_STOPPED undefined
Attachments
File | Date | Size |
---|---|---|
video.mp4 | 2018-01-04T10:09:21.000+0000 | 383631 |
As discussed yesterday, release 7.0.0 replaced the underlaying API of the Ti.Media.VideoPlayer (MPMoviePlayerController) with the most recent API (AVPlayerViewController) that has a slightly different API. [~vijaysingh] will have more insight here, but the newer way of getting the current video state is to use the
playbackState
property itself, rather than the constants. I think the docs still need to be updated there and some parity work was missing in the initial 7.0.0. Scheduling this ticket for 7.1.0 to address the documentation- and possible parity-issues. For this particular case: To check whether the movie is currently playing, check if theplaybackState
property returns a value > 0.PR (master): https://github.com/appcelerator/titanium_mobile/pull/9714 PR (7_0_X): https://github.com/appcelerator/titanium_mobile/pull/9715 Test-Case (use the attached mp4 file, as well as the test-case above):
FR passed.
Verified fix is found in: SDK 7.0.2.v20180124113923 SDK 7.1.0.v20180124115505