So it seems that the variable audioPlayer is defined within, and
is local to this function viewDidLoad.
And I'm trying to use it here, in the playSlowAudio function.
To fix this, I can declare it as a global variable at the top here.
And I can remove the initialization from within viewDidLoad.
So the variable AudioPlayer is of type AVAudioPlayer.
It's being declared here, initialized here, and used here.
All right, let's run this project.
I'll go to the second scene and then click on this button.
>> My mama always said, life was like a box of chocolates.
>> All right, we have sound.
،لذا، فيبدو أن المتغير audioPlayer محدد بالداخل
.وموجود محليًا في هذه الدالة viewDidLoad
.وسأحاول استخدامه هنا في الدالة playSlowAudio
.لحل هذا الأمر، يمكنني أن أعلنه كمتغير عام في الأعلى هنا
.ويمكنني إزالة التهيئة من داخل viewDidLoad
.لذا، فإن المتغير AudioPlayer من نوع AVAudioPlayer
.يتم إعلانه هنا، وتهيئته هنا، واستخدامه هنا
.حسنًا، لنشغل هذا المشروع
.سأنتقل إلى المشهد الثاني ثم أنقر فوق هذا الزر
.>> My mama always said, life was like a box of chocolates
.>> حسنًا، لدينا صوت
Parece que a variável audioPlayer está definida interiormente e
é local para esta função viewDidLoad.
E estou tentando usá-la aqui, na função playSlowAudio.
Para corrigir isso, posso declará-la como uma variável global aqui em cima.
E posso remover a inicialização de dentro de viewDidLoad.
Assim, a variável audioPlayer é do tipo AVAudioPlayer.
Está sendo declarada aqui, inicializada aqui e usada aqui.
Certo, vamos executar este projeto.
Vou para a segunda cena e clicar neste botão.
>> Minha mãe sempre disse que a vida era como uma caixa de chocolate.
>> Certo, temos som.