Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4053814
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:29:42+00:00 2026-05-20T14:29:42+00:00

I’m scripting with the VLC browser plugin to determine the length of any video

  • 0

I’m scripting with the VLC browser plugin to determine the length of any video file. I first tell VLC to attempt to play the file. Then I periodically probe it for its length. Once it tells me the length is non-zero, I know the video has successfully begun playing and the length is accurate.

The hard part is error detection. I have to detect if the supplied file is a busted video or not even video at all. Someone could lie with a text file incorrectly named as video.avi and VLC wouldn’t be able to play it. I arbitrarily decided that if VLC reports the length as 0 for 5 straight seconds, then I’d consider the supplied file a dud. Is this an accurate assumption? Is it possible that a severely fragmented harddrive would take more then 5 seconds to supply VLC with a video file? Does the bitrate of the file have anything to do with read time?

Below a snippet of my Javascript which determines the file length. You don’t have to read it to understand my question, but some of you might like to see it.

/**
 * Find the total length of a playlist item.
 *
 * @param PlaylistItem playlistItem
 * @param options
 *    onSuccess: void function(int length)
 *    onFailure: void function() - timeout
 *    onComplete: void function() - called after onSuccess or onFailure
 * @return void
 */
findLength: function(playlistItem, options) {
    var option = {
        onSuccess: Prototype.emptyFunction,
        onFailure: Prototype.emptyFunction,
        onComplete: Prototype.emptyFunction
    };

    Object.extend(option, options);

    if (playlistItem.getLength() > 0) {
        option.onSuccess(playlistItem.getLength());
        option.onComplete();
    }

    if (this.lengthPoller) {
        this.lengthPoller.stop();
    }

    this.preview(playlistItem);

    this.lengthPoller = new PeriodicalExecuter(
        function(poller) {
            if (this.secondsInComa >= MYAPP.Vlc.MAX_SECONDS_IN_COMA) {
                this.secondsInComa = 0;
                option.onFailure();
                this.stop();
                poller.stop();
                option.onComplete();
            } else {
                var currLength = this.vlc.input.length;
                if (currLength > 0) {
                    currLength /= 1000;
                    playlistItem.setLength(currLength);
                    option.onSuccess(currLength);
                    this.secondsInComa = 0;
                    this.stop();
                    poller.stop();
                    option.onComplete();
                } else {
                    this.secondsInComa += MYAPP.Vlc.LENGTH_POLLING_PERIOD;
                }
            }
        }.bind(this),
        MYAPP.Vlc.LENGTH_POLLING_PERIOD
    );
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T14:29:43+00:00Added an answer on May 20, 2026 at 2:29 pm

    I found out that it can take greater than 5 seconds. Windows will put a harddrive to sleep if it’s inactive. I tried to load up a video from an inactive drive. It took greater than 5 seconds for the drive to spool up. My code incorrectly marked the video as defective.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.