This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (AudioStreamBasicDescription)parseAudioFileData:(AudioFileID)audioFileID | |
error:(NSError **)error { | |
AudioStreamBasicDescription buffDataFormat; | |
UInt32 formatSize = sizeof(AudioStreamBasicDescription); | |
OSStatus status = AudioFileGetProperty(audioFileID, kAudioFilePropertyDataFormat, &formatSize, &buffDataFormat); | |
if (status != noErr) { | |
NSLog(@"parseAudioFileData failed %d", status); | |
*error = [NSError errorWithDomain:@"parse data format failed" code:-100 userInfo:nil]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (AudioFileID)loadAudioFile:(NSString *)audioPath { | |
AudioFileID audioFile; | |
OSStatus status = AudioFileOpenURL( | |
(__bridge CFURLRef _Nonnull)([NSURL fileURLWithPath:audioPath]), | |
kAudioFileReadPermission, | |
0, | |
&audioFile); | |
if (status != noErr) { | |
NSLog(@"Load file failed %d", status); | |
return nil; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static const UInt32 maxBufferSize = 0x10000; | |
static const UInt32 minBufferSize = 0x4000; | |
static const UInt32 maxBufferNum = 3; | |
@interface AudioPlayerManager() { | |
AudioFileID _audioFile; | |
AudioStreamBasicDescription _dataFormat; | |
AudioQueueRef _queue; | |
UInt32 numPacketsToRead; | |
AudioStreamPacketDescription *packetDescs; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *audioFilePath = [NSString stringWithFormat:@"%@", | |
[[NSBundle mainBundle] pathForResource:@"success-notification-alert_A_major" | |
ofType:@"wav"]]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void getHighlightableChildren(Widget* currentHighlightWiget, WidgetList& list) { | |
// 取得該 Widget 在哪個頁面上 | |
Page* pagePtr = currentHighlightWiget->getParentPage(); | |
const WidgetList& children = pagePtr->getChildren(); | |
Layer* layer = NULL; | |
// 取得 highlightable list,部分可用 recursive 方式判斷 isHighlightable() 這個 method 得到 | |
for (WidgetList::const_iterator it = children.begin(); it != children.end(); ++it) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool moveHighlight(DirectionType direction) { | |
bool moved = false; | |
Widget *currentHighlightedWidget = getHighlightedWidget(); | |
// 若目前沒有 highlight,嘗試尋找一個可以被 highlight 的物件 | |
if (NULL == currentHighlightedWidget) { | |
setupHighlighted(); | |
moved = hasHighlightedWidget(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Widget { | |
public: | |
Widget(); | |
~Widget(); | |
public: | |
void setHighlighted(); | |
void setHighlightable(bool active); | |
void resetHighlight(); | |
bool isHighlighted(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LibraryPage: Page { | |
lazy var libraryTab = app.tabBars.buttons["Library"] | |
var selectIndex: Int = 0 | |
func switchToLibrary() -> Self { | |
libraryTab.tap() | |
snapshot("switch to library page") | |
return self | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Page { | |
open var app:XCUIApplication | |
required init(_ app: XCUIApplication) { | |
self.app = app | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ReplayKit | |
class ViewController: UIViewController { | |
@IBOutlet weak var mainView: UIView! | |
var broadcastPicker: RPSystemBroadcastPickerView? | |
override func viewDidLoad() { | |
super.viewDidLoad() |