Should I rather be doing something like this? But I don´t know if this will have any affect on the error but its cleaner setup regardless I think.
<script crossorigin="anonymous" src="https://amp.azure.net/libs/amp/2.3.11/azuremediaplayer.min.js"></script>
<script>
var playerId;
var playerOptions;
var videoPlayer;
var videoSource;
if (Model.OnApple) {
playerId = "appleplayer";
videoSource = [{ src: "@Model.ManifestUrl", type: "application/vnd.ms-sstr+xml", streamingFormats: ["DASH", "SMOOTH"], protectionInfo: [{ type: "AES", authenticationToken: "@Model.Token" }] }, { src: "@Html.Raw(@Model.LiveStreamUrl)", type: "application/vnd.apple.mpegurl", disableUrlRewriter: true, protectionInfo: [{ type: "AES" }] }];
playerOptions = {
techOrder: ["azureHtml5JS", "html5"],
autoplay: true,
controls: true,
width: "100%",
height: "400",
poster: "",
"logo": { "enabled": false }
};
} else {
playerId = "azuremediaplayer";
videoSource = [{ src: "@Model.LiveStreamUrl", type: "application/vnd.ms-sstr+xml", protectionInfo: [{ type: "AES", authenticationToken: "@Model.Token" }] }];
playerOptions = {
autoplay: true,
controls: true,
width: "100%",
height: "400",
poster: "",
"logo": { "enabled": false }
};
}
document.getElementById("player-container").innerHTML = "<video id='" + playerId + "' class='azuremediaplayer amp-default-skin amp-big-play-centered'></video>";
videoPlayer = amp(playerId, playerOptions);
videoPlayer.src(videoSource);
var playerId;
var playerOptions;
var videoPlayer;
var videoSource;
var onApple = @Model.OnApple.ToString().ToLower();
if (onApple) {
playerId = "appleplayer";
videoSource = [{ src: "@Model.ManifestUrl", type: "application/vnd.ms-sstr+xml", streamingFormats: ["DASH", "SMOOTH"], protectionInfo: [{ type: "AES", authenticationToken: "@Model.Token" }] }, { src: "@Html.Raw(@Model.LiveStreamUrl)", type: "application/vnd.apple.mpegurl", disableUrlRewriter: true, protectionInfo: [{ type: "AES" }] }];
playerOptions = {
techOrder: ["azureHtml5JS", "html5"],
autoplay: true,
controls: true,
width: "100%",
height: "400",
poster: "",
"logo": { "enabled": false }
};
} else {
playerId = "azuremediaplayer";
videoSource = [{ src: "@Model.LiveStreamUrl", type: "application/vnd.ms-sstr+xml", protectionInfo: [{ type: "AES", authenticationToken: "@Model.Token" }] }];
playerOptions = {
autoplay: true,
controls: true,
width: "100%",
height: "400",
poster: "",
"logo": { "enabled": false }
};
}
document.getElementById("player-container").innerHTML = "<video id='" + playerId + "' class='azuremediaplayer amp-default-skin amp-big-play-centered'></video>";
videoPlayer = amp(playerId, playerOptions);
videoPlayer.src(videoSource);
</script>