MP4 doesn't play after initial load in Safari











up vote
1
down vote

favorite












I have embedded a mp4 file in my webpage, that gets loaded fine and is playable by every browser and on mobile too.



<video controls src="/mymovie.mp4">
<track kind="captions"></track>
</video>


However, when I open the webpage with Safari (macOS), the only thing I can see is a black box with the size of the video and a striked through (disabled) play button in front of it. The thing is, when I refresh the page again (even without clearing the cache) the video works fine.



enter image description here



When I write my markup to use the source element, the problem appears, but in a different way. Now I see no longer a black box, but a transparent one and I can press the play button, but the video won't start. I already tried to place a "not supported" text under the source list, but the text doesn't appear.



<video controls>
<track kind="captions"></track>
<source src="/mymovie.mp4" type="video/mp4"></source>
not supported
</video>


Notice that I already tried reordering the source element above the track element.



Is there any known problem of this kind and a way to solve it?



Here are some more informations about my setup:




  • HTTPS only (valid certificate)

  • video size is around 3,5MB

  • NGINX is configured to send this headers:


    • accept-ranges: bytes

    • Content-Range: bytes 262144-3411398/3411399

    • content-type: video/mp4




Something I notice in difference to Chrome is, that inside my devtools network tab the video source is loaded between 2 and 4 times, but just one time of it with the correct size. The other two entries are just some bytes. However, this happens in the same way, if I face the black box.










share|improve this question
























  • check this it may help you : stackoverflow.com/questions/30199261/…
    – DINA TAKLIT
    Nov 29 at 15:58










  • And this one too : stackoverflow.com/questions/27712778/…
    – DINA TAKLIT
    Nov 29 at 15:58










  • Yeah! The first link seems definitely to be useful. I will check some things out. Thank you!
    – Ole Bläsing
    Nov 29 at 17:02










  • happy to hear that :). wish u the best. I can search with you more till we find solution. let me know.
    – DINA TAKLIT
    Nov 29 at 17:30










  • could it be possible for you to upload the mp4 somewhere so that it can be downloaded and tested? also which version of Safari is it?
    – Narendra Mongiya
    Nov 30 at 4:46















up vote
1
down vote

favorite












I have embedded a mp4 file in my webpage, that gets loaded fine and is playable by every browser and on mobile too.



<video controls src="/mymovie.mp4">
<track kind="captions"></track>
</video>


However, when I open the webpage with Safari (macOS), the only thing I can see is a black box with the size of the video and a striked through (disabled) play button in front of it. The thing is, when I refresh the page again (even without clearing the cache) the video works fine.



enter image description here



When I write my markup to use the source element, the problem appears, but in a different way. Now I see no longer a black box, but a transparent one and I can press the play button, but the video won't start. I already tried to place a "not supported" text under the source list, but the text doesn't appear.



<video controls>
<track kind="captions"></track>
<source src="/mymovie.mp4" type="video/mp4"></source>
not supported
</video>


Notice that I already tried reordering the source element above the track element.



Is there any known problem of this kind and a way to solve it?



Here are some more informations about my setup:




  • HTTPS only (valid certificate)

  • video size is around 3,5MB

  • NGINX is configured to send this headers:


    • accept-ranges: bytes

    • Content-Range: bytes 262144-3411398/3411399

    • content-type: video/mp4




Something I notice in difference to Chrome is, that inside my devtools network tab the video source is loaded between 2 and 4 times, but just one time of it with the correct size. The other two entries are just some bytes. However, this happens in the same way, if I face the black box.










share|improve this question
























  • check this it may help you : stackoverflow.com/questions/30199261/…
    – DINA TAKLIT
    Nov 29 at 15:58










  • And this one too : stackoverflow.com/questions/27712778/…
    – DINA TAKLIT
    Nov 29 at 15:58










  • Yeah! The first link seems definitely to be useful. I will check some things out. Thank you!
    – Ole Bläsing
    Nov 29 at 17:02










  • happy to hear that :). wish u the best. I can search with you more till we find solution. let me know.
    – DINA TAKLIT
    Nov 29 at 17:30










  • could it be possible for you to upload the mp4 somewhere so that it can be downloaded and tested? also which version of Safari is it?
    – Narendra Mongiya
    Nov 30 at 4:46













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have embedded a mp4 file in my webpage, that gets loaded fine and is playable by every browser and on mobile too.



<video controls src="/mymovie.mp4">
<track kind="captions"></track>
</video>


However, when I open the webpage with Safari (macOS), the only thing I can see is a black box with the size of the video and a striked through (disabled) play button in front of it. The thing is, when I refresh the page again (even without clearing the cache) the video works fine.



enter image description here



When I write my markup to use the source element, the problem appears, but in a different way. Now I see no longer a black box, but a transparent one and I can press the play button, but the video won't start. I already tried to place a "not supported" text under the source list, but the text doesn't appear.



<video controls>
<track kind="captions"></track>
<source src="/mymovie.mp4" type="video/mp4"></source>
not supported
</video>


Notice that I already tried reordering the source element above the track element.



Is there any known problem of this kind and a way to solve it?



Here are some more informations about my setup:




  • HTTPS only (valid certificate)

  • video size is around 3,5MB

  • NGINX is configured to send this headers:


    • accept-ranges: bytes

    • Content-Range: bytes 262144-3411398/3411399

    • content-type: video/mp4




Something I notice in difference to Chrome is, that inside my devtools network tab the video source is loaded between 2 and 4 times, but just one time of it with the correct size. The other two entries are just some bytes. However, this happens in the same way, if I face the black box.










share|improve this question















I have embedded a mp4 file in my webpage, that gets loaded fine and is playable by every browser and on mobile too.



<video controls src="/mymovie.mp4">
<track kind="captions"></track>
</video>


However, when I open the webpage with Safari (macOS), the only thing I can see is a black box with the size of the video and a striked through (disabled) play button in front of it. The thing is, when I refresh the page again (even without clearing the cache) the video works fine.



enter image description here



When I write my markup to use the source element, the problem appears, but in a different way. Now I see no longer a black box, but a transparent one and I can press the play button, but the video won't start. I already tried to place a "not supported" text under the source list, but the text doesn't appear.



<video controls>
<track kind="captions"></track>
<source src="/mymovie.mp4" type="video/mp4"></source>
not supported
</video>


Notice that I already tried reordering the source element above the track element.



Is there any known problem of this kind and a way to solve it?



Here are some more informations about my setup:




  • HTTPS only (valid certificate)

  • video size is around 3,5MB

  • NGINX is configured to send this headers:


    • accept-ranges: bytes

    • Content-Range: bytes 262144-3411398/3411399

    • content-type: video/mp4




Something I notice in difference to Chrome is, that inside my devtools network tab the video source is loaded between 2 and 4 times, but just one time of it with the correct size. The other two entries are just some bytes. However, this happens in the same way, if I face the black box.







html safari






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 30 at 8:52

























asked Nov 22 at 15:34









Ole Bläsing

622522




622522












  • check this it may help you : stackoverflow.com/questions/30199261/…
    – DINA TAKLIT
    Nov 29 at 15:58










  • And this one too : stackoverflow.com/questions/27712778/…
    – DINA TAKLIT
    Nov 29 at 15:58










  • Yeah! The first link seems definitely to be useful. I will check some things out. Thank you!
    – Ole Bläsing
    Nov 29 at 17:02










  • happy to hear that :). wish u the best. I can search with you more till we find solution. let me know.
    – DINA TAKLIT
    Nov 29 at 17:30










  • could it be possible for you to upload the mp4 somewhere so that it can be downloaded and tested? also which version of Safari is it?
    – Narendra Mongiya
    Nov 30 at 4:46


















  • check this it may help you : stackoverflow.com/questions/30199261/…
    – DINA TAKLIT
    Nov 29 at 15:58










  • And this one too : stackoverflow.com/questions/27712778/…
    – DINA TAKLIT
    Nov 29 at 15:58










  • Yeah! The first link seems definitely to be useful. I will check some things out. Thank you!
    – Ole Bläsing
    Nov 29 at 17:02










  • happy to hear that :). wish u the best. I can search with you more till we find solution. let me know.
    – DINA TAKLIT
    Nov 29 at 17:30










  • could it be possible for you to upload the mp4 somewhere so that it can be downloaded and tested? also which version of Safari is it?
    – Narendra Mongiya
    Nov 30 at 4:46
















check this it may help you : stackoverflow.com/questions/30199261/…
– DINA TAKLIT
Nov 29 at 15:58




check this it may help you : stackoverflow.com/questions/30199261/…
– DINA TAKLIT
Nov 29 at 15:58












And this one too : stackoverflow.com/questions/27712778/…
– DINA TAKLIT
Nov 29 at 15:58




And this one too : stackoverflow.com/questions/27712778/…
– DINA TAKLIT
Nov 29 at 15:58












Yeah! The first link seems definitely to be useful. I will check some things out. Thank you!
– Ole Bläsing
Nov 29 at 17:02




Yeah! The first link seems definitely to be useful. I will check some things out. Thank you!
– Ole Bläsing
Nov 29 at 17:02












happy to hear that :). wish u the best. I can search with you more till we find solution. let me know.
– DINA TAKLIT
Nov 29 at 17:30




happy to hear that :). wish u the best. I can search with you more till we find solution. let me know.
– DINA TAKLIT
Nov 29 at 17:30












could it be possible for you to upload the mp4 somewhere so that it can be downloaded and tested? also which version of Safari is it?
– Narendra Mongiya
Nov 30 at 4:46




could it be possible for you to upload the mp4 somewhere so that it can be downloaded and tested? also which version of Safari is it?
– Narendra Mongiya
Nov 30 at 4:46












2 Answers
2






active

oldest

votes

















up vote
1
down vote













<video controls autoplay>
<source src="/mymovie.mp4" type="video/mp4">
<track kind="captions"></track>
</video>


Did you try using source tag instead? Autoplay attribute can also help, but some browsers do not allow videos to be autoplayed, or autoplay all videos as muted, if user didn't interract with document first. My best guess is that Safari doesn't allow to play a video without the prior interaction, and you refreshing the page do interact with the page. You can cheat it playing video after clicking on privacy policy accept button.



// jQuery
$('#button-id').click(function(){ $('#video-id').play(); });

// Javascript
var button = document.getElementById('button-id');
var video = document.getElementById('video-id');
button.addEventListener('click', function(){ video.play(); });





share|improve this answer





















  • I don't want to autoplay the video, but I will try the source element. Thank you!
    – Ole Bläsing
    Nov 26 at 16:43










  • I found some interesting news with the source approach. I've edited my question.
    – Ole Bläsing
    Nov 26 at 17:21












  • Well, I'm out of ideas. Did you try using another .mp4 file? Maybe encoding is the problem.
    – Lis
    Nov 27 at 14:06










  • Yeah, that is definitely possible. But wouldn't that disable the video always?
    – Ole Bläsing
    Nov 27 at 14:11


















up vote
1
down vote













If your video is in the same folder you should use:



    <video controls autoplay>
<source src="mymovie.mp4" type="video/mp4">
<track kind="captions"></track>
your browser doesn't support HTML5 video
</video>


or



    <video controls autoplay>
<source src="./mymovie.mp4" type="video/mp4">
<track kind="captions"></track>
your browser doesn't support HTML5 video
</video>


You could also include your whole url:



<video controls autoplay>
<source src="http://url.to/mymovie.mp4" type="video/mp4">
<track kind="captions"></track>
your browser doesn't support HTML5 video
</video>





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434216%2fmp4-doesnt-play-after-initial-load-in-safari%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    <video controls autoplay>
    <source src="/mymovie.mp4" type="video/mp4">
    <track kind="captions"></track>
    </video>


    Did you try using source tag instead? Autoplay attribute can also help, but some browsers do not allow videos to be autoplayed, or autoplay all videos as muted, if user didn't interract with document first. My best guess is that Safari doesn't allow to play a video without the prior interaction, and you refreshing the page do interact with the page. You can cheat it playing video after clicking on privacy policy accept button.



    // jQuery
    $('#button-id').click(function(){ $('#video-id').play(); });

    // Javascript
    var button = document.getElementById('button-id');
    var video = document.getElementById('video-id');
    button.addEventListener('click', function(){ video.play(); });





    share|improve this answer





















    • I don't want to autoplay the video, but I will try the source element. Thank you!
      – Ole Bläsing
      Nov 26 at 16:43










    • I found some interesting news with the source approach. I've edited my question.
      – Ole Bläsing
      Nov 26 at 17:21












    • Well, I'm out of ideas. Did you try using another .mp4 file? Maybe encoding is the problem.
      – Lis
      Nov 27 at 14:06










    • Yeah, that is definitely possible. But wouldn't that disable the video always?
      – Ole Bläsing
      Nov 27 at 14:11















    up vote
    1
    down vote













    <video controls autoplay>
    <source src="/mymovie.mp4" type="video/mp4">
    <track kind="captions"></track>
    </video>


    Did you try using source tag instead? Autoplay attribute can also help, but some browsers do not allow videos to be autoplayed, or autoplay all videos as muted, if user didn't interract with document first. My best guess is that Safari doesn't allow to play a video without the prior interaction, and you refreshing the page do interact with the page. You can cheat it playing video after clicking on privacy policy accept button.



    // jQuery
    $('#button-id').click(function(){ $('#video-id').play(); });

    // Javascript
    var button = document.getElementById('button-id');
    var video = document.getElementById('video-id');
    button.addEventListener('click', function(){ video.play(); });





    share|improve this answer





















    • I don't want to autoplay the video, but I will try the source element. Thank you!
      – Ole Bläsing
      Nov 26 at 16:43










    • I found some interesting news with the source approach. I've edited my question.
      – Ole Bläsing
      Nov 26 at 17:21












    • Well, I'm out of ideas. Did you try using another .mp4 file? Maybe encoding is the problem.
      – Lis
      Nov 27 at 14:06










    • Yeah, that is definitely possible. But wouldn't that disable the video always?
      – Ole Bläsing
      Nov 27 at 14:11













    up vote
    1
    down vote










    up vote
    1
    down vote









    <video controls autoplay>
    <source src="/mymovie.mp4" type="video/mp4">
    <track kind="captions"></track>
    </video>


    Did you try using source tag instead? Autoplay attribute can also help, but some browsers do not allow videos to be autoplayed, or autoplay all videos as muted, if user didn't interract with document first. My best guess is that Safari doesn't allow to play a video without the prior interaction, and you refreshing the page do interact with the page. You can cheat it playing video after clicking on privacy policy accept button.



    // jQuery
    $('#button-id').click(function(){ $('#video-id').play(); });

    // Javascript
    var button = document.getElementById('button-id');
    var video = document.getElementById('video-id');
    button.addEventListener('click', function(){ video.play(); });





    share|improve this answer












    <video controls autoplay>
    <source src="/mymovie.mp4" type="video/mp4">
    <track kind="captions"></track>
    </video>


    Did you try using source tag instead? Autoplay attribute can also help, but some browsers do not allow videos to be autoplayed, or autoplay all videos as muted, if user didn't interract with document first. My best guess is that Safari doesn't allow to play a video without the prior interaction, and you refreshing the page do interact with the page. You can cheat it playing video after clicking on privacy policy accept button.



    // jQuery
    $('#button-id').click(function(){ $('#video-id').play(); });

    // Javascript
    var button = document.getElementById('button-id');
    var video = document.getElementById('video-id');
    button.addEventListener('click', function(){ video.play(); });






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 26 at 11:43









    Lis

    19211




    19211












    • I don't want to autoplay the video, but I will try the source element. Thank you!
      – Ole Bläsing
      Nov 26 at 16:43










    • I found some interesting news with the source approach. I've edited my question.
      – Ole Bläsing
      Nov 26 at 17:21












    • Well, I'm out of ideas. Did you try using another .mp4 file? Maybe encoding is the problem.
      – Lis
      Nov 27 at 14:06










    • Yeah, that is definitely possible. But wouldn't that disable the video always?
      – Ole Bläsing
      Nov 27 at 14:11


















    • I don't want to autoplay the video, but I will try the source element. Thank you!
      – Ole Bläsing
      Nov 26 at 16:43










    • I found some interesting news with the source approach. I've edited my question.
      – Ole Bläsing
      Nov 26 at 17:21












    • Well, I'm out of ideas. Did you try using another .mp4 file? Maybe encoding is the problem.
      – Lis
      Nov 27 at 14:06










    • Yeah, that is definitely possible. But wouldn't that disable the video always?
      – Ole Bläsing
      Nov 27 at 14:11
















    I don't want to autoplay the video, but I will try the source element. Thank you!
    – Ole Bläsing
    Nov 26 at 16:43




    I don't want to autoplay the video, but I will try the source element. Thank you!
    – Ole Bläsing
    Nov 26 at 16:43












    I found some interesting news with the source approach. I've edited my question.
    – Ole Bläsing
    Nov 26 at 17:21






    I found some interesting news with the source approach. I've edited my question.
    – Ole Bläsing
    Nov 26 at 17:21














    Well, I'm out of ideas. Did you try using another .mp4 file? Maybe encoding is the problem.
    – Lis
    Nov 27 at 14:06




    Well, I'm out of ideas. Did you try using another .mp4 file? Maybe encoding is the problem.
    – Lis
    Nov 27 at 14:06












    Yeah, that is definitely possible. But wouldn't that disable the video always?
    – Ole Bläsing
    Nov 27 at 14:11




    Yeah, that is definitely possible. But wouldn't that disable the video always?
    – Ole Bläsing
    Nov 27 at 14:11












    up vote
    1
    down vote













    If your video is in the same folder you should use:



        <video controls autoplay>
    <source src="mymovie.mp4" type="video/mp4">
    <track kind="captions"></track>
    your browser doesn't support HTML5 video
    </video>


    or



        <video controls autoplay>
    <source src="./mymovie.mp4" type="video/mp4">
    <track kind="captions"></track>
    your browser doesn't support HTML5 video
    </video>


    You could also include your whole url:



    <video controls autoplay>
    <source src="http://url.to/mymovie.mp4" type="video/mp4">
    <track kind="captions"></track>
    your browser doesn't support HTML5 video
    </video>





    share|improve this answer

























      up vote
      1
      down vote













      If your video is in the same folder you should use:



          <video controls autoplay>
      <source src="mymovie.mp4" type="video/mp4">
      <track kind="captions"></track>
      your browser doesn't support HTML5 video
      </video>


      or



          <video controls autoplay>
      <source src="./mymovie.mp4" type="video/mp4">
      <track kind="captions"></track>
      your browser doesn't support HTML5 video
      </video>


      You could also include your whole url:



      <video controls autoplay>
      <source src="http://url.to/mymovie.mp4" type="video/mp4">
      <track kind="captions"></track>
      your browser doesn't support HTML5 video
      </video>





      share|improve this answer























        up vote
        1
        down vote










        up vote
        1
        down vote









        If your video is in the same folder you should use:



            <video controls autoplay>
        <source src="mymovie.mp4" type="video/mp4">
        <track kind="captions"></track>
        your browser doesn't support HTML5 video
        </video>


        or



            <video controls autoplay>
        <source src="./mymovie.mp4" type="video/mp4">
        <track kind="captions"></track>
        your browser doesn't support HTML5 video
        </video>


        You could also include your whole url:



        <video controls autoplay>
        <source src="http://url.to/mymovie.mp4" type="video/mp4">
        <track kind="captions"></track>
        your browser doesn't support HTML5 video
        </video>





        share|improve this answer












        If your video is in the same folder you should use:



            <video controls autoplay>
        <source src="mymovie.mp4" type="video/mp4">
        <track kind="captions"></track>
        your browser doesn't support HTML5 video
        </video>


        or



            <video controls autoplay>
        <source src="./mymovie.mp4" type="video/mp4">
        <track kind="captions"></track>
        your browser doesn't support HTML5 video
        </video>


        You could also include your whole url:



        <video controls autoplay>
        <source src="http://url.to/mymovie.mp4" type="video/mp4">
        <track kind="captions"></track>
        your browser doesn't support HTML5 video
        </video>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 30 at 15:59









        Bastiaan Buitelaar

        112




        112






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434216%2fmp4-doesnt-play-after-initial-load-in-safari%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Trompette piccolo

            Slow SSRS Report in dynamic grouping and multiple parameters

            Simon Yates (cyclisme)