{"action":"created","issue":{"url":"https://api.github.com/repos/sbooth/SFBAudioEngine/issues/53","labels_url":"https://api.github.com/repos/sbooth/SFBAudioEngine/issues/53/labels{/name}","comments_url":"https://api.github.com/repos/sbooth/SFBAudioEngine/issues/53/comments","events_url":"https://api.github.com/repos/sbooth/SFBAudioEngine/issues/53/events","html_url":"https://github.com/sbooth/SFBAudioEngine/issues/53","id":70999994,"number":53,"title":"SFBAudioEngine used in Swift project","user":{"login":"pzs7602","id":2361197,"avatar_url":"https://avatars.githubusercontent.com/u/2361197?v=3","gravatar_id":"","url":"https://api.github.com/users/pzs7602","html_url":"https://github.com/pzs7602","followers_url":"https://api.github.com/users/pzs7602/followers","following_url":"https://api.github.com/users/pzs7602/following{/other_user}","gists_url":"https://api.github.com/users/pzs7602/gists{/gist_id}","starred_url":"https://api.github.com/users/pzs7602/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pzs7602/subscriptions","organizations_url":"https://api.github.com/users/pzs7602/orgs","repos_url":"https://api.github.com/users/pzs7602/repos","events_url":"https://api.github.com/users/pzs7602/events{/privacy}","received_events_url":"https://api.github.com/users/pzs7602/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-04-26T02:49:04Z","updated_at":"2015-07-12T16:13:00Z","closed_at":null,"body":"I use SFBAudioEngine in my Swift project, since Swift can use C/C++ codes directly, I define a Objective C class wrapper for AudioPlayer:\r\n```\r\n#import <Foundation/Foundation.h>\r\n\r\n@interface AudioPlayerWrapper : NSObject{\r\n}\r\n- (id) init;\r\n- (void) playPause;\r\n- (void) seekForward;\r\n- (void) seekBackward;\r\n- (BOOL) playURL:(NSURL *)url;\r\n- (BOOL) isPlaying;\r\n- (BOOL) isPaused;\r\n- (BOOL) isStopped;\r\n- (BOOL) stop;\r\n\r\n@end\r\n\r\n#import \"AudioPlayerWrapper.h\"\r\n#include \"AudioPlayer.h\"\r\n#include \"AudioDecoder.h\"\r\n#include \"Logger.h\"\r\n\r\nenum ePlayerFlags : unsigned int {\r\n    ePlayerFlagRenderingStarted\t\t\t= 1u << 0,\r\n    ePlayerFlagRenderingFinished\t\t= 1u << 1\r\n};\r\n\r\n@interface AudioPlayerWrapper(){\r\n    SFB::Audio::Player\t*_player;\r\n    std::atomic_uint\t_playerFlags;\r\n}\r\n@end\r\n\r\n// AudioPlayerWrapper.m\r\n@implementation AudioPlayerWrapper\r\n- (id) init\r\n{\r\n    self = [super init];\r\n    if (self){\r\n        _player = new SFB::Audio::Player();\r\n        // This will be called from the realtime rendering thread and as such MUST NOT BLOCK!!\r\n        _player->SetRenderingStartedBlock(^(const SFB::Audio::Decoder& /*decoder*/){\r\n            _playerFlags.fetch_or(ePlayerFlagRenderingStarted);\r\n        });\r\n        \r\n        // This will be called from the realtime rendering thread and as such MUST NOT BLOCK!!\r\n        _player->SetRenderingFinishedBlock(^(const SFB::Audio::Decoder& /*decoder*/){\r\n            _playerFlags.fetch_or(ePlayerFlagRenderingFinished);\r\n        });\r\n        NSLog(@\"player created\");\r\n        asl_add_log_file(nullptr, STDERR_FILENO);\r\n        ::SFB::Logger::SetCurrentLevel(::SFB::Logger::debug);\r\n    }\r\n    return self;\r\n}\r\n\r\n- (void) playPause\r\n{\r\n    _player->PlayPause();\r\n}\r\n\r\n- (void) seekForward\r\n{\r\n    _player->SeekForward();\r\n}\r\n\r\n- (void) seekBackward\r\n{\r\n    _player->SeekBackward();\r\n}\r\n\r\n- (void) seek:(SInt64)position\r\n{\r\n    \r\n    SInt64 totalFrames;\r\n    if(_player->GetTotalFrames(totalFrames)) {\r\n        SInt64 desiredFrame = (SInt64)(position * totalFrames);\r\n        _player->SeekToFrame(desiredFrame);\r\n    }\r\n}\r\n\r\n- (BOOL) playURL:(NSURL *)url\r\n{\r\n    if(nil == url)\r\n        return NO;\r\n    return _player->Play((__bridge CFURLRef)url);\r\n}\r\n.....\r\n```\r\n\r\nIn Swift, play a flac audio file:\r\nself.myAudioPlayer = AudioPlayerWrapper()\r\nlet audioFileURL = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource(\"test\", ofType: \"flac\")!)\r\nself.myAudioPlayer!.playURL(audioFileURL)\r\n\r\nthe above code fail to play the flac file. I found the AudioDecoder is not created successfully:\r\n![2015-04-26 10 42 40](https://cloud.githubusercontent.com/assets/2361197/7335673/060dbcac-ec01-11e4-89c6-5adfde086c0f.png)\r\n\r\ndo I need to register the supported audio decoder(FLAC,APE,...) before playing?\r\nthanks! "},"comment":{"url":"https://api.github.com/repos/sbooth/SFBAudioEngine/issues/comments/120735483","html_url":"https://github.com/sbooth/SFBAudioEngine/issues/53#issuecomment-120735483","issue_url":"https://api.github.com/repos/sbooth/SFBAudioEngine/issues/53","id":120735483,"user":{"login":"sbooth","id":9965,"avatar_url":"https://avatars.githubusercontent.com/u/9965?v=3","gravatar_id":"","url":"https://api.github.com/users/sbooth","html_url":"https://github.com/sbooth","followers_url":"https://api.github.com/users/sbooth/followers","following_url":"https://api.github.com/users/sbooth/following{/other_user}","gists_url":"https://api.github.com/users/sbooth/gists{/gist_id}","starred_url":"https://api.github.com/users/sbooth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sbooth/subscriptions","organizations_url":"https://api.github.com/users/sbooth/orgs","repos_url":"https://api.github.com/users/sbooth/repos","events_url":"https://api.github.com/users/sbooth/events{/privacy}","received_events_url":"https://api.github.com/users/sbooth/received_events","type":"User","site_admin":false},"created_at":"2015-07-12T16:13:00Z","updated_at":"2015-07-12T16:13:00Z","body":"Is this still an problem? I'd like to close this issue if not."}}