diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index e0855c1e09..5a43208068 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -32,6 +32,7 @@ - [bilde2910](https://github.com/bilde2910) - [Daniel Hartung](https://github.com/dhartung) - [Ryan Hartzell](https://github.com/ryan-hartzell) + - [Thibault Nocchi](https://github.com/ThibaultNocchi) # Emby Contributors diff --git a/src/components/itemcontextmenu.js b/src/components/itemcontextmenu.js index 4e9bab6849..77ba2a6f49 100644 --- a/src/components/itemcontextmenu.js +++ b/src/components/itemcontextmenu.js @@ -346,23 +346,25 @@ 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 { - console.error("Failed to copy to clipboard"); - require(["toast"], function (toast) { - toast(globalize.translate("CopyStreamURLError")); - }); - } - - document.body.removeChild(textArea); + }, function () { + var textArea = document.createElement("textarea"); + textArea.value = downloadHref; + document.body.appendChild(textArea); + textArea.focus(); + textArea.select(); + if (document.execCommand("copy")) { + require(["toast"], function (toast) { + toast(globalize.translate("CopyStreamURLSuccess")); + }); + } else { + prompt(globalize.translate("CopyStreamURL"), downloadHref); + } + document.body.removeChild(textArea); + }); getResolveFunction(resolve, id)(); break; case "editsubtitles":