mediaelement / mediaelement

HTML5 <audio> or <video> player with support for MP4, WebM, and MP3 as well as HLS, Dash, YouTube, Facebook, SoundCloud and others with a common HTML5 MediaElement API, enabling a consistent UI in all browsers.
http://mediaelementjs.com/
MIT License
8.19k stars 1.58k forks source link

Can't play some FLV files + Some old issues #2329

Closed ignaciogros closed 7 years ago

ignaciogros commented 7 years ago

Hi, Rafael. Thanks a lot for maintaining MediaElement.

I'd like tu update eXeLearning's (https://github.com/exelearning/iteexe) version, but I found some problems:

I attach 2 versions (the mediaelement.js file is called exe_media.js in both cases, and it's loaded by common.js):

Just open the index.html files.

Thank you very much.

mediaelement-issues.zip

rafa8626 commented 7 years ago

Thanks for reporting this. I'll take a look and keep you posted

rafa8626 commented 7 years ago

Ok I've checked your test files and you will need to update this first on common.js:

     // Start MediaElement
     init: function() {
            $exe.mediaelements.mediaelementplayer({
                renderers: ['flash_video', 'html5'],
                stretching: 'none',
                pluginPath: typeof eXe !== 'undefined' ? '../scripts/mediaelement/' : ''
            }).show().each(function() {
                $exe.alignMediaElement(this)
            })
        }

I noticed that there's a JS code adding a display:inline to the video tag and that causes issues when we are dealing with Flash. You really wanna avoid using that. Other than that I think the update I posted fixes both of your issues. Let me know if it worked for you

rafa8626 commented 7 years ago

Please star the project to continue supporting it. Thanks

ignaciogros commented 7 years ago

Thanks, Rafael!

1.- I can't find the code that adds display:inline. Where did you see it?

2.- I tested in Windows with Firefox, G. Chrome and IE11:

video-sample.flv:

http://la2.indexcom.com/me/flv/guqin.flv:

Isn't 'html5', 'flash_video' the default setting? I think that trying to use HTML5 video in the first place would de better.

3.- This is not important: I had to remove from common.js the part that hides the videos and shows them again after aligning them. Otherwise the video was displayed in the wrong place. Example:

position_problem

Please star the project to continue supporting it. Thanks

Done! Thank you!

rafa8626 commented 7 years ago

The display: inline is what is causing that video to be in the wrong place. But I don't know which Javascript might be doing it because is not on MEJS. Now, as far as the renderers, since you are using I set it in that order because I didn't know if you had more video types. If you have also MP4, then yes, html5, flash_video is what you have to use.

rafa8626 commented 7 years ago

'html5', 'flash_video' is not the default setting: there are more renderers, including a native_flv which uses flv.js library. That library has some restrictions, so that's why sometimes FLV plays and sometimes don't. That's why you need to try to use Flash overall if you can't change your FLVs accordingly. At the same time, most of the browsers are deprecating Flash (Chrome, Edge and FF, for now), so at some point Flash is not gonna work at all. My advise always is to strive to use native but you may need to check the flv.js project to see requirements for videos, or change FLV to MP4

rafa8626 commented 7 years ago

Let me know if you have any other questions, and thanks for starring the project

ignaciogros commented 7 years ago

Hi, Rafael.

Is it possible to set different renderers to each media file in the page? Something like:

$exe.mediaelements.mediaelementplayer({
    renderers: getRenderers(),
    stretching: 'none',
    pluginPath: typeof eXe !== 'undefined' ? '../scripts/mediaelement/' : ''
});

In that case, I could set ['html5', 'flash_video', 'native_flv'] for the FLV files and [] for the rest (we don't know what video or audio will be played).

Another thing: When I try to play FLV in G. Chrome I get no error message. errorContent is empty, so I had to do this in mediaelement-and-player.js (line 4206):

if (!errorContent) {
    var lnk = t.media.originalNode.getAttribute('src');
    if (lnk) {
        errorContent = '<p><a href="' + lnk + '" download><span>' + _mejs2.default.i18n.t('mejs.download-file') + ': ' + lnk + '</span></a></p>';
    }
}

You might find a better way to fix that...

Thank you!

rafa8626 commented 7 years ago

If you play only one media file per page, yes you can. I will check the error content since it must display things correctly unless there's something missing on the renderer. Can you provide the URL to see that issue please?

rafa8626 commented 7 years ago

If you use something like this it will work for your scenario, I think no matter how many instances per page you have:

$exe.mediaelements.each(function(i, element) {
         // Or however your video tags are configured to find the source to be played
         var isFlv = $(element).attr('src').indexOf('flv') > -1;
         new MediaElementPlayer(element, {
               renderers: isFlv ? ['flash_video'] : [],
               stretching: 'none',
               pluginPath: typeof eXe !== 'undefined' ? '../scripts/mediaelement/' : ''
        });
}).show();

Just let me know the URL for the error issue so I can check why is not displaying anything

ignaciogros commented 7 years ago

Yes! Thanks for that code. The renderers part is solved. I don't know if the plugin should do that by default...

Please try this in G. Chrome (no error is displayed): http://gros.es/tests/exelearning/mediaelement/

With the code in line 4206 to check errorContent: http://gros.es/tests/exelearning/mediaelement/?test=true

rafa8626 commented 7 years ago

Perfect! I'll check the error issue. And no, the player should remain like it is because we don't know what circumstances the other users might be facing.

rafa8626 commented 7 years ago

OK download the master branch and test the error issue. I had a missing layer to display errors on native renderers. Let me know

ignaciogros commented 7 years ago

I still see no error message in G. Chrome: http://gros.es/tests/exelearning/mediaelement-master/

rafa8626 commented 7 years ago

Hmmm ok let me check it again. I had the issues being displayed if I used the local file. Can you try that, please?

rafa8626 commented 7 years ago

Interesting. I do see an error if I put this on the demo file; I don't know what's causing the effect on your side, because I am able to even see the console.error, and I don't see it on yours:

screen shot 2017-07-28 at 1 30 37 pm
ignaciogros commented 7 years ago

I tried a cleaner code (HTML5, just those JS files, etc.) just in case, but I still get no error messages in G. Chrome (on Windows): http://gros.es/tests/exelearning/mediaelement-master/clean.html Do you?

The error message is displayed if I set a customError. FR: It would be easier to show a link If you could use a function there: customError: function(element) { ... }

Could you provide the URL where you can see the error messages? I tried in different servers.

Thanks.

rafa8626 commented 7 years ago

I don't see any errors on your URL because I could see the videos in your page. I don't have a URL but the main website has the latest code. I agree with the customError and I'll implement that. I tested this on MacOSX and worked for me (I got a square indicating that Flash needed to be activated prior playing them, but that's it)

screen shot 2017-07-30 at 7 35 21 am screen shot 2017-07-30 at 7 36 19 am
rafa8626 commented 7 years ago

As an example, in the main website choose FLV, press play and click on the progress bar to a point that is not loaded yet. You can see the error being displayed

screen shot 2017-07-30 at 7 44 05 am
rafa8626 commented 7 years ago

I see in your statement about customError that you have an argument. What do you mean with element? Because it will be easier to set a method with no args right now

ignaciogros commented 7 years ago

Hi, Rafael.

I see in your statement about customError that you have an argument. What do you mean with element? Because it will be easier to set a method with no args right now

The video element object ([HTMLVideoElement]), so you can get the currentSrc, for example, or even 2 arguments: The MediaElement object and the HTML element.

rafa8626 commented 7 years ago

Sounds good I'll add it today. Other than that I think that's it. Can this ticket be closed?

ignaciogros commented 7 years ago

Of course! Closed.

Thanks a lot, Rafael!

rafa8626 commented 7 years ago

You are very welcome. Thank you for providing feedback and making a better player with your suggestions. BTW, the callback for customError is now implemented, so download the master branch and test it please. It accepts now the 2 arguments you mentioned above per your suggestion

ignaciogros commented 7 years ago

I see the changes in the errorContent definition, but the arguments are missing, at least in my tests: http://gros.es/tests/exelearning/mediaelement-master/clean.html

Try this one (FLV + renderers: ['html5']) in Firefox if you get no error in G. Chrome: http://gros.es/tests/exelearning/mediaelement-master/html5.html

rafa8626 commented 7 years ago

Ok I'll check this and let you know. Thanks

rafa8626 commented 7 years ago

I got it. I was using the wrong variables. Please download the master branch and let me know if it works now. Thanks for pointing this.

ignaciogros commented 7 years ago

It works. Thank you!

rafa8626 commented 7 years ago

You are welcome I'm glad it works now