Post

Replies

Boosts

Views

Activity

Cannot get Apple Media Service Bluetooth BLE to work With Various Bluetooth Boards or Arduino
Hello. Having a hard time with this one. The Apple Media Service is documented here (1). It seems like an elegant and simply system to control audio over BLE with a custom hardware solution. I have set up various boards I have, including Arduino Nano BLE and Adafruit Huzzah ESP32, using fairly straightforward scripts. This "device" I am building then should show up on the iPhone > Settings App > Bluetooth > Other Devices. I should able to connect to the device, and have it get media information from the iPhone and be able to control it What happens is a bit odd. First nothing shows up in Other Devices. I then use a BLE integrator app like BLE Scanner, and it shows up as Arduino (despite what I name it). I can connect to it, and interesting it lists APPLE MEDIA as a service UUID (which is correct!). Now if I go back to Settings App > Bluetooth, because I have connected to my device with BLE Scanner, it shows as connected and under "My Devices" ! However it doesn't work, no audio is controlled. As a test I tried flicking the Play Pause characteristic but it does nothing (can see it in the Arduino code below where it flips every 4 second). Is there an example of using Apple Media Device BLE control? I found one using MicroPython but I don't want to use micropython, and I am not sure what I am doing different. The Arduino code is here. I have been trying to get this to work for a while now, using many, many different boards / chips. Any help is appreciated: BLEService mediaService("89D3502B-0F36-433A-8EF4-C502AD55F8DC"); BLEUnsignedCharCharacteristic audioControlChar("9B3C81D8-57B1-4A8A-B8DF-0E56F7CA51C2", BLEWrite | BLENotify); BLEUnsignedCharCharacteristic entityUpdateChar("2F7CABCE-808D-411F-9A0C-BB92BA96C102", BLEWrite | BLENotify); BLEUnsignedCharCharacteristic entityAttributeChar("C6B2F38C-23AB-46D8-A6AB-A3A870BBD5D7", BLEWrite | BLERead); int playPauseSwitch = 1; // for now flip between 0 (pause) and play (1) on 9B3C81D8 characteristic, every 4 seconds long previousMillis = 0; // count for test to flip play pause void setup() { Serial.begin(9600); while (!Serial); pinMode(LED_BUILTIN, OUTPUT); // begin initialization if (!BLE.begin()) { Serial.println("starting BLE failed!"); while (1); } BLE.setLocalName("MediaController"); mediaService.addCharacteristic(audioControlChar); mediaService.addCharacteristic(entityUpdateChar); mediaService.addCharacteristic(entityAttributeChar); BLE.setAdvertisedService(mediaService); // add the service UUID BLE.addService(mediaService); BLE.advertise(); Serial.println("Bluetooth device active, waiting for connections..."); } void loop() { // wait for a BLE central BLEDevice central = BLE.central(); // if a central is connected to the peripheral: if (central) { Serial.print("Connected to central: "); // print the central's BT address: Serial.println(central.address()); // turn on the LED to indicate the connection: digitalWrite(LED_BUILTIN, HIGH); while (central.connected()) { long currentMillis = millis(); // For now flip play pause characteristics every 4 seconds if (currentMillis - previousMillis >= 4000) { previousMillis = currentMillis; flipPlayPause(); } } // when the central disconnects, turn off the LED: digitalWrite(LED_BUILTIN, LOW); Serial.print("Disconnected from central: "); Serial.println(central.address()); } } void flipPlayPause() { if (playPauseSwitch == 0) { playPauseSwitch = 1; } else { playPauseSwitch = 0; } audioControlChar.writeValue(playPauseSwitch); } (1) - Apple BLE Media Service https://developer.apple.com/library/archive/documentation/CoreBluetooth/Reference/AppleMediaService_Reference/Introduction/Introduction.html#//apple_ref/doc/uid/TP40014716-CH2-SW1
3
1
2.4k
Jan ’22
Immense static noise from speakers if project includes video
Hello, I am building a project that embeds a normal mp4 video with sound. The video plays fine in Mac OS. I then embed into my project. As soon as I launch the project, even if its just showing SwiftUI view, it completely messes up the sound coming out of my Mac - everything then sounds like it has static. I have to restart my Mac to get the sound back to normal. This is with Xcode 13.1
0
0
419
Nov ’21
Very slow performance with SwiftUI Canvas and Fish Eye Transform sample code
Hello! SwiftUI canvas looks great for my needs. I tried it out by using the Canvas with Gesture sample code in the "WWDC21 What's New in SwiftUI" session, 22 minutes in. I am running it on Xcode 13.0 Beta on M1 MacBook Air with Big Sur, on the iPad Pro 11 iOS 15 simulator I maybe get 2 or 3 frames a second, not even close to what is being shown in the video What am I missing? thx PS. It's virtually impossible to copy sample code in the MacOS WWDC Developer app
2
0
1.5k
Jun ’21
Xcode 12 hangs on MacBook M1 constantly
Unfortunately my new M1 MacBook Air with 16GB when running Xcode 12 constantly hangs. The project is a fairly straightforward SwiftUI project with no 3rd party libraries It hangs, or freezes. Sometimes the spinner comes up, sometimes not. Sometimes it works for a few minutes, sometimes it hangs bad enough I need to force quit it. Anyone else experiencing this? I installed it from the Mac App Store. Nothing else is running beside Safari. Nothing seems to be eating the CPU in activity monitor.
1
0
1.6k
Feb ’21
MPMediaQuery is always nil for Movie or TV Shows
Hello,I can no longer query for user's Movie or TV Shows. This used to work before iOS 9. MPMediaPropertyPredicate *predicate = [MPMediaPropertyPredicate predicateWithValue:[NSNumber numberWithInteger:MPMediaTypeMovie] forProperty:MPMediaItemPropertyMediaType]; MPMediaQuery *query = [[MPMediaQuery alloc] init]; [query addFilterPredicate:predicate]; NSArray *items = [query items];Returns nothing. As does MPMediaTypeTVShow.Any hints ? Thanks.
2
1
753
Jan ’16