Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4135] iOS: VIDEO_REPEAT_MODE_ONE repeats forever

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2012-03-26T11:09:37.000+0000
Affected Version/sRelease 1.7.0
Fix Version/sn/a
ComponentsiOS
LabelsCLA
ReporterDawson Toth
AssigneeBlain Hamon
Created2011-05-18T14:34:38.000+0000
Updated2017-03-24T18:21:10.000+0000

Description

Problem

"VIDEO_REPEAT_MORE_ONE" (herewithin "ONE") repeats the video forever. The docs state, "the video will repeat once", so something is not quite right.

Solution

Add a third constant, "VIDEO_REPEAT_MODE_INFINITE", and bind that to the existing behavior of "ONE". Then fix "ONE" so that it will repeat just once.

Sample Code

The following code will repeat forever if the bug is present. Drop it in an app.js, and it will download the mp4 before it plays it.
var win = Ti.UI.createWindow({ backgroundColor: '#000' });
var url = 'http://theatercrew.com/sample.mp4';
var file = Ti.Filesystem.getFile('file:///sdcard/').exists()
        ? Ti.Filesystem.getFile('file:///sdcard/sample.mp4')
        : Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'sample.mp4');

function playVideo() {
    var video = Ti.Media.createVideoPlayer({
        url: file.nativePath,
        repeatMode: Ti.Media.VIDEO_REPEAT_MODE_ONE
    });
    if (parseFloat(Ti.Platform.version) >= 3.2) {
        win.add(video);
    }
    video.play();
}
function downloadVideo() {
    var progress = Ti.UI.createProgressBar({ max: 1, min: 0, value: 0, visible: true });
    win.add(progress);
    var client = Ti.Network.createHTTPClient({
        ondatastream: function(e) {
            progress.value = e.progress;
        },
        onload: function() {
            file.write(this.responseData);
            win.remove(progress);
            playVideo();
        }
    });
    client.open('GET', url);
    client.send();
}

if (file.exists()) {
    playVideo();
}
else {
    downloadVideo();
}

win.open();

Associated Helpdesk Ticket

http://appc.me/c/APP-667723

Comments

  1. Blain Hamon 2011-07-05

    This is a documentation bug, not a code bug. The documentation for the video SHOULD BE: "constant for repeating one video setting", akin to MUSIC_PLAYER_REPEAT_ONE. That is, the 'one' indicates number of items to repeat nonstop, not number of times to repeat it.
  2. Blain Hamon 2012-03-26

    As of this posting, the documentation correctly notes: {quote} name: VIDEO_REPEAT_MODE_ONE summary: Constant for repeating one video (i.e., the one video will repeat constantly) during playback. {quote} Closing this bug as invalid.
  3. Lee Morris 2017-03-24

    Closing ticket as invalid with reference to the above comments.

JSON Source