[TIMOB-18055] Titanium VideoPlayer initialPlaybackTime setting does not work for second video in VideoPlayer
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | TiAPI |
Labels | initialplaybacktime, ios, media, playlist, videoplayer |
Reporter | Patrick van Vuuren |
Assignee | Unknown |
Created | 2014-11-18T15:04:41.000+0000 |
Updated | 2018-02-28T19:55:06.000+0000 |
Description
Hello,
I am using a playlist to simulate some kind of Live-TV.
When the user initially opens the window and plays the video, the initialplaybacktime is set correctly of the video.
Then if the user stops the video by clicking on it (Looks like it's being paused but actually it's stopped ($.video.stop()) to reload the playlist and get the live elapsed time) and then clicks it again.
When the user clicks it after it's stopped, the playlist is reloaded and the current video is set as url and it's elapsed time is set with setInitialPlaybackTime().
But this doesn't work, and it results into a 'NaN' if I try to retrieve it the playback has started the second time, so not the initial time the user opens the window.
Testcase
var win = Ti.UI.createWindow({
exitOnClose: true,
layout: 'vertical'
});
var url = "http://clips.vorwaerts-gmbh.de/VfE_html5.mp4";
var videoPlayer = Ti.Media.createVideoPlayer({
top: 0,
scalingMode: Ti.Media.VIDEO_SCALING_ASPECT_FIT,
autoplay: false,
width: Ti.Platform.displayCaps.platformWidth,
height: Ti.Platform.displayCaps.platformWidth * (9/16), // 16:9 ratio on the screen
fullscreen: false,
mediaControlStyle: Ti.Media.VIDEO_CONTROL_NONE
});
videoPlayer.addEventListener('playbackstate', function(e) {
if(e.playbackState == Ti.Media.VIDEO_PLAYBACK_STATE_PLAYING) {
btn.title = "Stop";
Ti.API.info("Initial playback videoPlayer on state change: "+this.getInitialPlaybackTime());
Ti.API.info("Current playback videoPlayer on state change: "+this.getCurrentPlaybackTime());
} else if(e.playbackState == Ti.Media.VIDEO_PLAYBACK_STATE_STOPPED) {
btn.title = "Play";
}
});
win.add(videoPlayer);
var btn = Ti.UI.createButton({
top: 20,
width: "60%",
height: 40,
title: "Play"
});
btn.addEventListener("click", function() {
if(videoPlayer.playbackState == Ti.Media.VIDEO_PLAYBACK_STATE_PLAYING) {
videoPlayer.stop();
videoPlayer.url = "";
} else {
var initialPlayback = Math.floor((Math.random() * 10000) + 1000); // random initial
Ti.API.info("Initial playback: "+initialPlayback);
Ti.API.info("Initial playback videoPlayer on click: "+videoPlayer.getInitialPlaybackTime());
Ti.API.info("Current playback videoPlayer on click: "+videoPlayer.getCurrentPlaybackTime());
videoPlayer.setInitialPlaybackTime(initialPlayback);
videoPlayer.setUrl(url);
videoPlayer.play();
}
});
win.add(btn);
win.open();
This code exactly shows in the logs that it does not work.
Regards,
Patrick van Vuuren
Problem can be reproduced on iOS 8.1, SDK 3.4.0