From 4dc5535a024a6162a1b1443489eb72187e0e30fe Mon Sep 17 00:00:00 2001 From: dkanada Date: Sun, 15 Mar 2020 18:47:19 +0900 Subject: [PATCH] Merge pull request #936 from macr/master Fix "Copy Stream URL" for iOS. (cherry picked from commit 0b107b37701173bade89c3b9f978783d74762075) Signed-off-by: Joshua M. Boniface --- src/components/itemcontextmenu.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/itemcontextmenu.js b/src/components/itemcontextmenu.js index 62048345ea..bdbcfc782b 100644 --- a/src/components/itemcontextmenu.js +++ b/src/components/itemcontextmenu.js @@ -346,11 +346,7 @@ define(["apphost", "globalize", "connectionManager", "itemHelper", "appRouter", break; case "copy-stream": var downloadHref = apiClient.getItemDownloadUrl(itemId); - navigator.clipboard.writeText(downloadHref).then(function () { - require(["toast"], function (toast) { - toast(globalize.translate("CopyStreamURLSuccess")); - }); - }, function () { + var textAreaCopy = function () { var textArea = document.createElement("textarea"); textArea.value = downloadHref; document.body.appendChild(textArea); @@ -364,7 +360,16 @@ define(["apphost", "globalize", "connectionManager", "itemHelper", "appRouter", prompt(globalize.translate("CopyStreamURL"), downloadHref); } document.body.removeChild(textArea); - }); + }; + if (navigator.clipboard === undefined) { + textAreaCopy(); + } else { + navigator.clipboard.writeText(downloadHref).then(function () { + require(["toast"], function (toast) { + toast(globalize.translate("CopyStreamURLSuccess")); + }); + }, textAreaCopy); + } getResolveFunction(resolve, id)(); break; case "editsubtitles":