1//2// SomeController.swift3// Some App4//5// Created by Lvov Yury on 12/7/15.6//78importUIKit910classSecondScreenController:UIViewController{1112var mytimer:Timer?13var tictac ="clock";1415overridefuncviewDidLoad(){16super.viewDidLoad()1718// Do any additional setup after loading the view, typically from a nib.19self.mytimer =Timer.scheduledTimer(timeInterval:1, target:self, selector: #selector(SecondScreenController.update_screen), userInfo:nil, repeats:true);20self.update_screen();21}2223overridefuncviewWillAppear(_ animated:Bool){24super.viewWillAppear(animated)25}2627funcupdate_screen(){2829self.play_animation();30self.playSound(self.tictac )31}3233funcplaySound(_ melody:String){34// NSLog(melody)35let audioFilePath =Bundle.main.path(forResource: melody, ofType:"mp3")3637if audioFilePath !=nil{3839let audioFileUrl =URL(fileURLWithPath: audioFilePath!)40do{41self.audioPlayer =tryAVAudioPlayer(contentsOf: audioFileUrl, fileTypeHint:nil)42}catch_{43return// if it doesn't exist, don't play it44}4546self.audioPlayer.numberOfLoops =0;47self.audioPlayer.play()48}else{49// println("audio file is not found")50}51}5253funcplay_animation(){54// Some animation55}56}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。