Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
The code below works perfectly in Dev and Stage environment but not Production. Can provide more of the code if helps.
@functions{ private bool isSafari { get { var userAgent = HttpContext.Current.Request.UserAgent; return !string.IsNullOrEmpty(userAgent) && userAgent.Contains("Safari") && userAgent.Contains("Mac OS"); } } }
Are you getting any errors?
I am not seeing any script errors in the console if that is what you are referring to. Should I check anywhere else?
What I am trying to do is playing an mp4 file if the browser is Safari, otherwise a Webm should play.
@if (Model.value.mp4 != null && Model.value.mp4.value != null) { var mp4Media = Umbraco.Media((string)Model.value.mp4.value); if (isSafari && mp4Media != null) // Use the isSafari variable here { <video autoplay loop muted playsinline style="width: 100%; @styleValue" title="@Model.value.altText.value"> <source src="@mp4Media.Url" type="video/mp4" style="@styleValue" class="@(Model.value.mediaClass != null ? Model.value.mediaClass.value : string.Empty)" /> <source src="@image.Url" type="video/webm" style="@styleValue" class="@(Model.value.mediaClass != null ? Model.value.mediaClass.value : string.Empty)" /> Your browser does not support the video. </video> } else { <video autoplay loop muted playsinline style="width: 100%; @styleValue" title="@Model.value.altText.value"> <source src="@image.Url" type="video/webm" style="@styleValue" class="@(Model.value.mediaClass != null ? Model.value.mediaClass.value : string.Empty)" /> <source src="@mp4Media.Url" type="video/mp4" style="@styleValue" class="@(Model.value.mediaClass != null ? Model.value.mediaClass.value : string.Empty)" /> Your browser does not support the video. </video> } }
What exactly happens in prod? Is anything rendered?
The webm plays first in both Safari and Chrome. In staging and dev, the mp4 plays first in Safari and the webm plays first in chrome.
Are you able to log what it thinks the user agent is?
Yes, I am also using a browser testing tool/and asked a colleague with a macbook to view the video on the page and the code is not working as it should.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Why will this code not work in my production environment?
The code below works perfectly in Dev and Stage environment but not Production. Can provide more of the code if helps.
Are you getting any errors?
I am not seeing any script errors in the console if that is what you are referring to. Should I check anywhere else?
What I am trying to do is playing an mp4 file if the browser is Safari, otherwise a Webm should play.
What exactly happens in prod? Is anything rendered?
The webm plays first in both Safari and Chrome. In staging and dev, the mp4 plays first in Safari and the webm plays first in chrome.
Are you able to log what it thinks the user agent is?
Yes, I am also using a browser testing tool/and asked a colleague with a macbook to view the video on the page and the code is not working as it should.
is working on a reply...