在开关盒中显示多个视频

时间:2017-02-09 00:08:53

标签: swift

我正在尝试将视频传递到switch case语句中。例如当你点击每个鸡尾酒时,它应该加载一个不同的视频,但是我得到一个糟糕的线程执行错误。我需要以某种方式找到一种方法来实现每个鸡尾酒的视频,并确保这些不同。以下是此课程的代码。非常感谢帮助。

var passdata: String = ""

var toPass:String!
var cocktails = ["Mojito","Long Island Iced Tea","Sex On The Beach","Screaming Orgasum","Cosmo","Strawberry Summer Sling","Rosini Royal","Blue Lagoon"]


@IBOutlet weak var labelpassdata: UILabel!

@IBOutlet weak var WebView: UIWebView!

var playerViewController = AVPlayerViewController()
var playerView = AVPlayer()

override func viewDidLoad() {
    super.viewDidLoad()

    passdata = cocktails[0]
    switch toPass
    {
    case cocktails[0]:
    let fileURL = NSURL(fileURLWithPath: "/Users/marcusgriffiths/Desktop/iosApp 2/MrCocktailsMenu/How to Make a Mojito  Cocktail Recipes.mp4")

    WebView.loadHTMLString("<iframe width = \"\(self.WebView.frame.width) \"height = \"\(self.WebView.frame.height)\" src = \"\(fileURL)\"> </iframe>", baseURL: nil)
    case cocktails[1]:
    let fileURL = NSURL(fileURLWithPath: "/Users/marcusgriffiths/Desktop/iosApp 2/MrCocktailsMenu/How To Make The Long Island Iced Tea - Bartender Style.mp4")

    WebView.loadHTMLString("<iframe width = \"\(self.WebView.frame.width) \"height = \"\(self.WebView.frame.height)\" src = \"\(fileURL)\"> </iframe>", baseURL: nil)
case cocktails[2]:
    let fileURL = NSURL(fileURLWithPath: "/Users/marcusgriffiths/Desktop/iosApp 2/MrCocktailsMenu/Sex on the Beach Vodka Cocktail _ Joel Fraser.mp4")

    WebView.loadHTMLString("<iframe width = \"\(self.WebView.frame.width) \"height = \"\(self.WebView.frame.height)\" src = \"\(fileURL)\"> </iframe>", baseURL: nil)
case cocktails[3]:
    let fileURL = NSURL(fileURLWithPath: "/Users/marcusgriffiths/Desktop/iosApp 2/MrCocktailsMenu/(Screaming) Orgasm - Drink Recipe.mp4")

    WebView.loadHTMLString("<iframe width = \"\(self.WebView.frame.width) \"height = \"\(self.WebView.frame.height)\" src = \"\(fileURL)\"> </iframe>", baseURL: nil)
case cocktails[4]:
    let fileURL = NSURL(fileURLWithPath: "/Users/marcusgriffiths/Desktop/iosApp 2/MrCocktailsMenu/How to make a Cosmopolitan cocktail - by Cointreau.mp4")

    WebView.loadHTMLString("<iframe width = \"\(self.WebView.frame.width) \"height = \"\(self.WebView.frame.height)\" src = \"\(fileURL)\"> </iframe>", baseURL: nil)
case cocktails[5]:
    let fileURL = NSURL(fileURLWithPath: "/Users/marcusgriffiths/Desktop/iosApp 2/MrCocktailsMenu/Strawberry Sling Alcoholic Video Recipe Thermochef cheekyricho.mp4")

    WebView.loadHTMLString("<iframe width = \"\(self.WebView.frame.width) \"height = \"\(self.WebView.frame.height)\" src = \"\(fileURL)\"> </iframe>", baseURL: nil)
case cocktails[6]:
    let fileURL = NSURL(fileURLWithPath: "/Users/marcusgriffiths/Desktop/iosApp 2/MrCocktailsMenu/Rossini Cocktail _ Jamie Oliver.mp4")

    WebView.loadHTMLString("<iframe width = \"\(self.WebView.frame.width) \"height = \"\(self.WebView.frame.height)\" src = \"\(fileURL)\"> </iframe>", baseURL: nil)
case cocktails[7]:
    let fileURL = NSURL(fileURLWithPath: "")

    WebView.loadHTMLString("<iframe width = \"\(self.WebView.frame.width) \"height = \"\(self.WebView.frame.height)\" src = \"\(fileURL)\"> </iframe>", baseURL: nil)

          passdata = cocktails[0]
    default: break
    }
}

0 个答案:

没有答案