frankyghost / projekktor

The Free Web Video Player
194 stars 75 forks source link

Regex for auto-detecting filetype by inspecting the video url is broken #14

Open sattes-faction opened 10 years ago

sattes-faction commented 10 years ago

I'm not quite sure if this is a bug or misconfiguration on my site but I've ran into the following problems:

I'm having a video element like this one:

    <video width="560" height="315" controls poster="https://media.example.com/videos/video_standbild_560x315.jpg">
      <source src="https://media.example.com/videos/video_560x315.mp4" type="video/mp4">
    </video>

Which I'm initializing with these options:

{
  autoplay: true,
  volume: 0.8,
  platforms: ['flash']
}

So, basically I want to limit it to a specific platform, 'flash' in this example (any other would produce the same error, though). Projekktor fails in that case with an error message in line 2680 (function _getTypeFromFileExtension).

The problem is that the regex in the try/catch block before this line ALWAYS fails (at least in my case). The regex never returns a proper result because the function parameter url is not a string but an array. This then always sets fileExt='NaN' in the catch block. This file extension is not part of the extTypes array and so an error is thrown.

I just found out that the file extension "NaN" exists if you don't limit the platforms and therefore this error does not popup though the regex fails here, too.

Can someone confirm this?

rwlodkowski commented 10 years ago

You must always add 'browser' to the platforms array. So no matter what the config must look like:

{
platforms: ['browser', <any_other_platorms> ]
}

Probably it could be always added by default no matter of user setting.

sattes-faction commented 10 years ago

Yeah, thanks - this works now. Would be a good idea to add it by default in order to avoid this pitfall. But is the regex functioning properly? I was somewhat confused it always returns NaN in my cases. But maybe I just did not look close enough.

rwlodkowski commented 10 years ago

As I know the regex functionality is broken. I will try to sort it out.