Trouble with passing variable string to playAudio()

Method in line 30 requires a string argument. console.log(this.baseUrl) prints the URL correctly till line 29. But this.baseUrl when passed as an argument to playAudio in line 30 doesn’t work. Giving the URL straightaway within single quotes as in this.streamingMedia.playAudio(‘https://dannybritto.000webhostapp.com/surviva.mp3’, options); work fine. I’m getting the URL from the user. So I need to pass a string variable to playAudio(). Please help.

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { StreamingMedia, StreamingAudioOptions } from '@ionic-native/streaming-media';
@Component({
  selector: 'page-home',
  templateUrl: 'home.html',
  providers: [
  StreamingMedia
  ]
})
export class HomePage {
  mp3=""
  audioUrl: string;
  baseUrl: string;
  logForm(){
  this.audioUrl = this.mp3
  this.baseUrl = "'"+this.audioUrl+"'"
  console.log(this.baseUrl)
  }
  constructor(private streamingMedia: StreamingMedia) {
  }
  startAudio() {
    let options: StreamingAudioOptions = {
    successCallback: () => { console.log('Finished Audio')},
    errorCallback: (e) => { console.log('Error: ', e)},
  };
  console.log(this.baseUrl)
  this.streamingMedia.playAudio(this.baseUrl, options);
}
}

Why do we have three separate properties (mp3, baseUrl, and audioUrl) all storing the same data? Why are you declaring a per-component StreamingMedia provider? What is going on with all the extra quoting?

I was browsing all over the internet and did whatever I came across. I want to get the form value where [(ngModel)] = “mp3” and pass it as a string with single quotes to playAudio() method. I’m a noob. Please help me out.

I don’t intend for this to be overly harsh, but in what other profession would this make sense? If you heard this from a doctor or lawyer or mechanic, what would you think?

I understand. I am stuck with this for a couple of days.

Finally did it!

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { StreamingMedia, StreamingAudioOptions } from '@ionic-native/streaming-media';
var audioUrl: URL

@Component({
  selector: 'page-home',
  templateUrl: 'home.html',
  providers: [
  StreamingMedia,
  ]
})
export class HomePage {
  mp3=""
  logForm(){
  audioUrl = new URL(this.mp3)
  }
  constructor(private streamingMedia: StreamingMedia) {

  }
  startAudio() {
    let options: StreamingAudioOptions = {
    successCallback: () => { console.log('Finished Audio')},
    errorCallback: (e) => { console.log('Error: ', e)},
  };
  console.log(audioUrl.href.toString())
  this.streamingMedia.playAudio(`${audioUrl.href.toString()}`, options);

}
}