Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6742] iOS: Video duration not available on device

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionWon't Fix
Resolution Date2011-12-17T17:51:58.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sSprint 2011-50
ComponentsiOS
Labelsn/a
ReporterStephen Tramer
AssigneeStephen Tramer
Created2011-12-17T15:59:49.000+0000
Updated2017-03-03T23:17:20.000+0000

Description

Apparently the video duration is not available on device, even after the video begins playing or goes through a thumbnail grab (it may not be available beforehand, due to Apple bugs or other issues).
var win = Titanium.UI.currentWindow;
win.backgroundColor = '#FFFFFF'

var close_button = Titanium.UI.createButton({
    title:'Close'
});

win.leftNavButton = close_button;

close_button.addEventListener('click', function(e) {
    win.close();
});

var activeMovie = Titanium.Media.createVideoPlayer(
{
    url : 'http://c0222252.cdn.cloudfiles.rackspacecloud.com/0032_MotoBlur.m4v',
    mediaControlStyle:Titanium.Media.VIDEO_CONTROL_DEFAULT,
    scalingMode:Titanium.Media.VIDEO_SCALING_ASPECT_FIT,
    autoplay : false
});

activeMovie.addEventListener('complete',function()
{
    Ti.API.info ("[test_duration.js] Movie completed");
    Ti.API.info ("[test_duration.js] duration after playing: " + activeMovie.duration);
});


//win.add(activeMovie);


var selected_video_thumbnail = activeMovie.thumbnailImageAtTime (5, Titanium.Media.VIDEO_TIME_OPTION_NEAREST_KEYFRAME);
Ti.API.info ("[test_duration.js] duration after getting thumbnail: " + activeMovie.duration);
Support ticket: http://support.appcelerator.com/tickets/APP-792614/tickets Should make a drillbit or KS test available.

Comments

  1. Stephen Tramer 2011-12-17

    Duration cannot be retrieved until the "durationAvailable" event is triggered. Looking into the best way to manually trigger that event now, because there is no guarantee that the duration is valid until that event is received. For large video stored remotely, this could take some time, especially on radio connections.
  2. Stephen Tramer 2011-12-17

    Tested iPod 4GT / iOS 5.0.1 over WiFi (no WWAN support). Here are the findings: Video does not necessarily have all of its metadata loaded immediately after a request, especially for large remote files. You cannot get the duration until a video specifically says that the duration is available via the "durationAvailable" event. This property is documented, and so this bug is being marked "WON'T FIX" instead of being handled to docs (although the documentation could probably be better). Sample code which displays the MOST CORRECT behavior:
       var win = Ti.UI.createWindow();
       win.backgroundColor = '#FFFFFF'
       
       var close_button = Titanium.UI.createButton({
           title:'Close'
       });
       
       win.leftNavButton = close_button;
       
       close_button.addEventListener('click', function(e) {
           win.close();
       });
       
       var activeMovie = Titanium.Media.createVideoPlayer(
       {
           url : 'http://c0222252.cdn.cloudfiles.rackspacecloud.com/0032_MotoBlur.m4v',
           mediaControlStyle:Titanium.Media.VIDEO_CONTROL_DEFAULT,
           scalingMode:Titanium.Media.VIDEO_SCALING_ASPECT_FIT,
           autoplay : false
       });
       
       activeMovie.addEventListener('complete',function()
       {
           Ti.API.info ("[test_duration.js] Movie completed");
           Ti.API.info ("[test_duration.js] duration after playing: " + activeMovie.duration);
       });
       
       
       //win.add(activeMovie);
       
       activeMovie.addEventListener("durationAvailable", function() {
       	Ti.API.info ("[test_duration.js] duration after getting thumbnail: " + activeMovie.duration);
       });
       
       var selected_video_thumbnail = activeMovie.thumbnailImageAtTime (5, Titanium.Media.VIDEO_TIME_OPTION_NEAREST_KEYFRAME);
       
  3. Stephen Tramer 2011-12-17

    Filed a doc bug (TIMOB-6743) indicating that there may be a lack of useful information available about when certain metadata values are valid.
  4. David Geller 2011-12-25

    The 'durationAvailable' event never seems to appear for Android in 1.8.0.1.
  5. Lee Morris 2017-03-03

    Closing ticket.

JSON Source