diff --git a/src/components/itemcontextmenu.js b/src/components/itemcontextmenu.js index 4e9bab6849..192bd821da 100644 --- a/src/components/itemcontextmenu.js +++ b/src/components/itemcontextmenu.js @@ -346,23 +346,16 @@ define(["apphost", "globalize", "connectionManager", "itemHelper", "appRouter", break; case "copy-stream": var downloadHref = apiClient.getItemDownloadUrl(itemId); - var textArea = document.createElement("textarea"); - textArea.value = downloadHref; - document.body.appendChild(textArea); - textArea.focus(); - textArea.select(); - if (document.execCommand("copy")) { + navigator.clipboard.writeText(downloadHref).then(function () { require(["toast"], function (toast) { toast(globalize.translate("CopyStreamURLSuccess")); }); - } else { + }, function () { console.error("Failed to copy to clipboard"); require(["toast"], function (toast) { toast(globalize.translate("CopyStreamURLError")); }); - } - - document.body.removeChild(textArea); + }); getResolveFunction(resolve, id)(); break; case "editsubtitles":