Playing audio from a web plugin in Nativescript iOS WebView












0















I came across a plugin that plays the sound of a given chord. This plugin was developed to be used in browsers. I have managed to implement it using Nativescript WebView on Android. The problem is that it is not working on iOs. Here is the index.html code:



<!DOCTYPE html>
<html>
<body>
<script>
context = new AudioContext();
function playChordSound(cho){
window.cp.buildChordPlayer(cho, context).play();
}
</script>

<button id="playChordBtn"></button>

<script src="./lib/nativescript-webview-interface.js"></script>
<script src="./index.js"></script>
<!-- <script src="https://www.scales-chords.com/api/scales-chords-api.js"></script> -->
<script src="./chordplayer/src/dist/main.js"></script>
</body>
</html>


Do I have to set some permissions or load something before the plugin can use iOs WebView sound capabilities?



Thank you very much.










share|improve this question

























  • You don't need any special permissions to play audio using default HTML5 audio controls. Can you create a Playground example where we can see the issue?

    – Manoj
    Nov 23 '18 at 6:29













  • your path to the audio file maybe wrong in iOS. Can you post your code ?

    – DotNet Dreamer
    Nov 25 '18 at 13:14











  • Hi @Manoj, I've added some code to the question. As I mentioned before, on Android this code works fine.

    – Ricardo de Paula Soares
    Dec 8 '18 at 1:21











  • I think chordplayer library may not loaded as expected into your WebView. Try to make sure the path is correct and it's loaded. Also try to setup a Playground, it will be easier to debug.

    – Manoj
    Dec 8 '18 at 17:35











  • @Manoj thank you for trying to help. I really appreciate that. But all I need to know is if this line is right: AudioContext = new (window.AudioContext || window.webkitAudioContext); It works on Android.

    – Ricardo de Paula Soares
    Dec 15 '18 at 3:35
















0















I came across a plugin that plays the sound of a given chord. This plugin was developed to be used in browsers. I have managed to implement it using Nativescript WebView on Android. The problem is that it is not working on iOs. Here is the index.html code:



<!DOCTYPE html>
<html>
<body>
<script>
context = new AudioContext();
function playChordSound(cho){
window.cp.buildChordPlayer(cho, context).play();
}
</script>

<button id="playChordBtn"></button>

<script src="./lib/nativescript-webview-interface.js"></script>
<script src="./index.js"></script>
<!-- <script src="https://www.scales-chords.com/api/scales-chords-api.js"></script> -->
<script src="./chordplayer/src/dist/main.js"></script>
</body>
</html>


Do I have to set some permissions or load something before the plugin can use iOs WebView sound capabilities?



Thank you very much.










share|improve this question

























  • You don't need any special permissions to play audio using default HTML5 audio controls. Can you create a Playground example where we can see the issue?

    – Manoj
    Nov 23 '18 at 6:29













  • your path to the audio file maybe wrong in iOS. Can you post your code ?

    – DotNet Dreamer
    Nov 25 '18 at 13:14











  • Hi @Manoj, I've added some code to the question. As I mentioned before, on Android this code works fine.

    – Ricardo de Paula Soares
    Dec 8 '18 at 1:21











  • I think chordplayer library may not loaded as expected into your WebView. Try to make sure the path is correct and it's loaded. Also try to setup a Playground, it will be easier to debug.

    – Manoj
    Dec 8 '18 at 17:35











  • @Manoj thank you for trying to help. I really appreciate that. But all I need to know is if this line is right: AudioContext = new (window.AudioContext || window.webkitAudioContext); It works on Android.

    – Ricardo de Paula Soares
    Dec 15 '18 at 3:35














0












0








0








I came across a plugin that plays the sound of a given chord. This plugin was developed to be used in browsers. I have managed to implement it using Nativescript WebView on Android. The problem is that it is not working on iOs. Here is the index.html code:



<!DOCTYPE html>
<html>
<body>
<script>
context = new AudioContext();
function playChordSound(cho){
window.cp.buildChordPlayer(cho, context).play();
}
</script>

<button id="playChordBtn"></button>

<script src="./lib/nativescript-webview-interface.js"></script>
<script src="./index.js"></script>
<!-- <script src="https://www.scales-chords.com/api/scales-chords-api.js"></script> -->
<script src="./chordplayer/src/dist/main.js"></script>
</body>
</html>


Do I have to set some permissions or load something before the plugin can use iOs WebView sound capabilities?



Thank you very much.










share|improve this question
















I came across a plugin that plays the sound of a given chord. This plugin was developed to be used in browsers. I have managed to implement it using Nativescript WebView on Android. The problem is that it is not working on iOs. Here is the index.html code:



<!DOCTYPE html>
<html>
<body>
<script>
context = new AudioContext();
function playChordSound(cho){
window.cp.buildChordPlayer(cho, context).play();
}
</script>

<button id="playChordBtn"></button>

<script src="./lib/nativescript-webview-interface.js"></script>
<script src="./index.js"></script>
<!-- <script src="https://www.scales-chords.com/api/scales-chords-api.js"></script> -->
<script src="./chordplayer/src/dist/main.js"></script>
</body>
</html>


Do I have to set some permissions or load something before the plugin can use iOs WebView sound capabilities?



Thank you very much.







nativescript






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 8 '18 at 1:17







Ricardo de Paula Soares

















asked Nov 22 '18 at 23:55









Ricardo de Paula SoaresRicardo de Paula Soares

115




115













  • You don't need any special permissions to play audio using default HTML5 audio controls. Can you create a Playground example where we can see the issue?

    – Manoj
    Nov 23 '18 at 6:29













  • your path to the audio file maybe wrong in iOS. Can you post your code ?

    – DotNet Dreamer
    Nov 25 '18 at 13:14











  • Hi @Manoj, I've added some code to the question. As I mentioned before, on Android this code works fine.

    – Ricardo de Paula Soares
    Dec 8 '18 at 1:21











  • I think chordplayer library may not loaded as expected into your WebView. Try to make sure the path is correct and it's loaded. Also try to setup a Playground, it will be easier to debug.

    – Manoj
    Dec 8 '18 at 17:35











  • @Manoj thank you for trying to help. I really appreciate that. But all I need to know is if this line is right: AudioContext = new (window.AudioContext || window.webkitAudioContext); It works on Android.

    – Ricardo de Paula Soares
    Dec 15 '18 at 3:35



















  • You don't need any special permissions to play audio using default HTML5 audio controls. Can you create a Playground example where we can see the issue?

    – Manoj
    Nov 23 '18 at 6:29













  • your path to the audio file maybe wrong in iOS. Can you post your code ?

    – DotNet Dreamer
    Nov 25 '18 at 13:14











  • Hi @Manoj, I've added some code to the question. As I mentioned before, on Android this code works fine.

    – Ricardo de Paula Soares
    Dec 8 '18 at 1:21











  • I think chordplayer library may not loaded as expected into your WebView. Try to make sure the path is correct and it's loaded. Also try to setup a Playground, it will be easier to debug.

    – Manoj
    Dec 8 '18 at 17:35











  • @Manoj thank you for trying to help. I really appreciate that. But all I need to know is if this line is right: AudioContext = new (window.AudioContext || window.webkitAudioContext); It works on Android.

    – Ricardo de Paula Soares
    Dec 15 '18 at 3:35

















You don't need any special permissions to play audio using default HTML5 audio controls. Can you create a Playground example where we can see the issue?

– Manoj
Nov 23 '18 at 6:29







You don't need any special permissions to play audio using default HTML5 audio controls. Can you create a Playground example where we can see the issue?

– Manoj
Nov 23 '18 at 6:29















your path to the audio file maybe wrong in iOS. Can you post your code ?

– DotNet Dreamer
Nov 25 '18 at 13:14





your path to the audio file maybe wrong in iOS. Can you post your code ?

– DotNet Dreamer
Nov 25 '18 at 13:14













Hi @Manoj, I've added some code to the question. As I mentioned before, on Android this code works fine.

– Ricardo de Paula Soares
Dec 8 '18 at 1:21





Hi @Manoj, I've added some code to the question. As I mentioned before, on Android this code works fine.

– Ricardo de Paula Soares
Dec 8 '18 at 1:21













I think chordplayer library may not loaded as expected into your WebView. Try to make sure the path is correct and it's loaded. Also try to setup a Playground, it will be easier to debug.

– Manoj
Dec 8 '18 at 17:35





I think chordplayer library may not loaded as expected into your WebView. Try to make sure the path is correct and it's loaded. Also try to setup a Playground, it will be easier to debug.

– Manoj
Dec 8 '18 at 17:35













@Manoj thank you for trying to help. I really appreciate that. But all I need to know is if this line is right: AudioContext = new (window.AudioContext || window.webkitAudioContext); It works on Android.

– Ricardo de Paula Soares
Dec 15 '18 at 3:35





@Manoj thank you for trying to help. I really appreciate that. But all I need to know is if this line is right: AudioContext = new (window.AudioContext || window.webkitAudioContext); It works on Android.

– Ricardo de Paula Soares
Dec 15 '18 at 3:35












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439217%2fplaying-audio-from-a-web-plugin-in-nativescript-ios-webview%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439217%2fplaying-audio-from-a-web-plugin-in-nativescript-ios-webview%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Futebolista

Feedback on college project

Albești (Vaslui)