translate typescript to javascript : <p>I need this code is in <strong>Javascript</strong></p>

<p>I am not specialized in language typescript.</p>

<p>this is code for play music and record audio in mobile with nativescript</p>

<p>do not think <strong>GitHub</strong> quickly give answer</p>

<p><a href="https://github.com/bradmartin/nativescript-audio/issues/56" rel="nofollow noreferrer">in github issues</a></p>

<pre><code>import { TNSPlayer } from 'nativescript-audio';

export class YourClass {
    private _player: TNSPlayer;

    constructor() {
        this._player = new TNSPlayer();
        this._player.initFromFile({
            audioFile: '~/audio/song.mp3', // ~ = app directory
            loop: false,
            completeCallback: this._trackComplete.bind(this),
            errorCallback: this._trackError.bind(this)
        }).then(() =&gt; {

            this._player.getAudioTrackDuration().then((duration) =&gt; {
                // iOS: duration is in seconds
                // Android: duration is in milliseconds
                console.log(`song duration:`, duration);
            });
        });
    }

    public togglePlay() {
        if (this._player.isAudioPlaying()) {
            this._player.pause();
        } else {
            this._player.play();
        }
    }

    private _trackComplete(args: any) {
        console.log('reference back to player:', args.player);

        // iOS only: flag indicating if completed succesfully
        console.log('whether song play completed successfully:', args.flag);
    }

    private _trackError(args: any) {
        console.log('reference back to player:', args.player);
        console.log('the error:', args.error);

        // Android only: extra detail on error
        console.log('extra info on the error:', args.extra);
    }
}
</code></pre>
