Posts

Post not yet marked as solved
0 Replies
316 Views
As per WidgetKit TimelineProvider documentation: "When your app is in the foreground, has an active media session, or is using the standard location service, refreshes don’t count against the widget’s daily limit. For more information about media sessions and location services, see AVAudioSession and Configuring your app to use location services." That suggests that I should be able to reload my widget from the background with the most up to date details of the active media session. However, that doesn't appear to be working either when trying to reload all timelines or just a specific one. All other background processing is working fine in the app otherwise, including the media playback. Media session is started by the following code: do { try AVAudioSession.sharedInstance().setCategory(.playback, options: .mixWithOthers) print("AVAudioSession Category Playback OK") try AVAudioSession.sharedInstance().setActive(true) print("AVAudioSession is Active") print(AVAudioSession.sharedInstance()) } catch let error as NSError { print(error.localizedDescription) } let item = AVPlayerItem(url: URL(string: "https://cdn.smartersoft-group.com/various/pull-bell-short.mp3")!) self.queuePlayer = AVQueuePlayer(playerItem: item) self.queuePlayer?.volume = 0.0 self.playerLooper = AVPlayerLooper(player: self.queuePlayer!, templateItem: item) self.queuePlayer?.playImmediately(atRate: 1.0) self.queuePlayer?.volume = 2.0 Wondering if I am misunderstanding the documentation and it's not a supported use case or a bug. FB12782013 has been submitted.
Posted Last updated
.
Post not yet marked as solved
3 Replies
431 Views
I am listening to DLNA notifications over TCP and for about a minute, my NWListener instance keeps receiving new notifications but after about a minute, it stops getting the notifications. NWListener is still alive at that point and the DLNA subscription is valid as well. No such issues when listening using GCDWebserver. Am I missing something obvious with NWListener?
Posted Last updated
.
Post not yet marked as solved
0 Replies
726 Views
Wondering if it possible to post HID Gamepad events to the system similar to keyboard and mouse NSEvent or CGEvent. I am able to monitor gamepad events and get the usage value via IOHIDElementGetUsage (48 and 49 for the axis) and the value via IOHIDValueGetIntegerValue. I would like to generate these same events from code to simulate them without any actual controller attached to the system.
Posted Last updated
.
Post not yet marked as solved
1 Replies
733 Views
This is the only thing I found re: low-level networking on WatchOS: developer.apple.com/forums/thread/127232 Is this still the case? Both NWListener and NWConnection are working in Simulator but not on physical device. Is this expected? The below class works in the simulator but on physical device creating and starting the listener doesn't return anything in the stateUpdateHandler class Connect: ObservableObject {     static let sharedInstance = Connect()     private var talking: NWConnection?     private var listening: NWListener?     @Published var incomingUDPMessage: String = ""     func listenUDP(port: NWEndpoint.Port) {         print("IP Address:")         print(getIpAddress())         do {             self.listening = try NWListener(using: .tcp, on: port)             print("listening params")             print(self.listening?.service)             self.listening?.stateUpdateHandler = {(newState) in                 switch newState {                 case .ready:                 print("ready to listen")                 default:                 break                 }             }             self.listening?.newConnectionHandler = {(newConnection) in                 newConnection.stateUpdateHandler = {newState in                     switch newState {                     case .ready:                     print("new connection")                     self.receive(on: newConnection)                     default:                     break                     }                 }                 newConnection.start(queue: DispatchQueue(label: "new client"))                 }             } catch {         print("unable to create listener")         }         self.listening?.start(queue: .main)     }// END OF FUNC - LISTEN TO UDP     func receive(on connection: NWConnection) {         connection.receiveMessage { (data, context, isComplete, error) in             if let error = error {   print(error)                 return             }             if let data = data, !data.isEmpty {                 let incomingString = String(decoding: data, as: UTF8.self)                     print("Incoming String")       print(incomingString)                     self.listening?.cancel()             }         }     }// END OF FUNC - RECEIVE }// END OF CLASS - CONNECT
Posted Last updated
.