//
//  storage.swift
//  JukeStarter
//
//  Created by Emuel Aldridge on 10/28/20.
//

import SwiftUI
import AVFoundation
struct SongSetup: View {
    var artist = "Rolling Stones"
    var songTitle = "Paint it Black"
    var artistImage = "stones"
    var soundFile = "stones.m4a"
    var body: some View {
        VStack {
            Button(action: {
                playsound(thesong: soundFile)
            }) {
                VStack {
                    Text(artist)
                        .font(.headline)
                        .fontWeight(.bold)
                        .foregroundColor(Color.black)
                    Text(songTitle)
                        .fontWeight(.bold)
                        .foregroundColor(Color.black)
                        .multilineTextAlignment(.center)
                        .lineLimit(2)
                 
                    Image(artistImage)
              
                }
             
            }

           
        }
    }
}

func playsound (thesong: String){
    let thepath = Bundle.main.path(forAuxiliaryExecutable: thesong)!
let url = URL(fileURLWithPath: thepath)
do {
    twist = try AVAudioPlayer(contentsOf: url)
    twist?.play()
} catch {
    // couldn't load file :(
}
}


func paws(){
    twist?.pause()
}
func player(){
    twist?.play()
}
