ios - 设置RubyMotion应用以播放背景音频

标签 ios audio background rubymotion

我是RubyMotion的新手,我试图弄清楚如何配置我的应用程序,以便在单击“主页”按钮并将应用程序移至后台后继续播放音乐。在我的Rakefile中,我有:

$:.unshift("/Library/RubyMotion/lib")
require 'motion/project/template/ios'

begin
  require 'bundler'
  require 'bubble-wrap'
  Bundler.require
  require 'sugarcube-classic'
rescue LoadError
end

Motion::Project::App.setup do |app|
  app.name = 'test_music_app'
  app.frameworks << 'AVFoundation'
  app.frameworks << 'AudioToolbox'
  app.background_modes = [:audio]
end

在我的app_delegate.rb中:
UIApplication.sharedApplication.beginReceivingRemoteControlEvents
AVAudioSession.sharedInstance.setDelegate(self)
AVAudioSession.sharedInstance.setCategory(AVAudioSessionCategoryPlayback, error:nil)
AVAudioSession.sharedInstance.setActive(true, error:nil)

我似乎找不到为此提供的文档或Stack Overflow支持,因此任何帮助对自己以及试图启动并运行RubyMotion音乐应用程序的其他人都将非常有用。

最佳答案

我认为MusicPlayer和音频工具箱在模拟器上不起作用。您是否尝试过使用设备?

关于ios - 设置RubyMotion应用以播放背景音频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19298245/

相关文章:

ios - Apple Watch App - 基于页面的应用程序和分层应用程序的混合方法

ios - Realm swift : Realm at path already opened with different schema version

c# - 用于 MP3 编辑的音频库

c++ - ffmpeg:音频样本的字节顺序

jquery - 更改横幅中的背景

ios - 我是否需要最新版本的 Xcode 才能将应用程序提交到应用程序商店?

ios - ios UITest 中的间歇性 "Failure attempting to launch"

ios - 通知声音不想通过硬件键关闭

css - Drupal:CSS 中区域背景图像的无效属性值

iphone - 应用程序处于后台状态时 AVPlayer 处理缓冲区