Is there a callback for failed media playbacks in the Google Cast iOS Framework? I wasn't able to find anything useful in the documentation or the sample apps on github.
Specifically, I'm looking for load errors of HLS streams... So in case CORS isn't properly configured, the parsing of *.m3u8 files fails, I want the sender iOS app to know about.
This is the closest I have found:
- (void)deviceManager:(GCKDeviceManager *)deviceManager didFailToConnectToApplicationWithError:(NSError *)error
- (void)deviceManager:(GCKDeviceManager *)deviceManager didFailToConnectWithError:(NSError *)error
However, if connecting to the device, and launching the receiver application succeed, these callbacks will never fire.
Thanks for your help!
Found it!
- (void)mediaControlChannel:(GCKMediaControlChannel *)mediaControlChannel didFailToLoadMediaWithError:(NSError *)error
Related
We are working on a bluetooth project using cordova as a xplatform development tool.
We are developing for android and iOS and writing a BLE plugin for cordova ourselves.
On Android everything is running fine. Now comes the problem:
On iOS we are able to read/write and even subscribe to notifications.
The problem comes when we try to receive a updated value, then nothing happens.
In short
- connect to device
- discover services
- discover characterics
- subscribe to notification characteristic
this is working well:
-(void)peripheral:(CBPeripheral *)peripheral didUpdateNotificationStateForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
is getting called, and characteristic.isNotifying is true
When doing a simple read operation on the characteristics, the
-(void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
callback is being called.
Here comes the problem:
When updating the value from the peripheral, the callback simply does not get called.
We have no clue were to look since no errors occur at all, so maybe somebody knows a way to debug this issue?
Note: When connecting to the peripheral using a external tool, subscribing to the characteristic and updating it's value. The notification is received. It's iOS specific.
Ok the problem was:
We were calling [peripheral setNotificaiton:etc] on the temporary peripheral received by the callback.
When we are setting the notification on the onConnected stored peripheral object, notifications are received. (self.peripheral)
No this was not the answer, it was working because we restarted the iOS device. It looks like there is some sort of bug in this crappy apple thing.
Does anybody know how to restart bluetooth programmatically?
I have a problem with launching media from iOS app. When I call mediaControlChannel loadMedia:, nothing happens on receiver app - no loading bar appears, but neither of GCKMediaControlChannelDelegate methods are being called. After waiting some time, when I disconnect from the device, only then delegate receives didFailToLoadMediaWithError with error 92: unexpected disconnect.
I thought that the media or some of the parameters are incorrect, so I used them in Google's example iOS app, but it all works fine there.
Before trying to load media I check if I'm connected to device and to the application, mediaControlChannel is added to deviceManager. I also call requestStatus on mediaControlChannel to make sure I don't get kGCKInvalidRequestID and everything's fine. Only then I try to load media, but as I said - it just doesn't work, no error, no feedback from receiver app. I'm out of ideas.
On start app i called AudioSessionInitialize and check result value.
If it was kAudioSessionInitializationError then i informed user that application can not work properly cause audio does not work.
But since iOS 7 this function was deprecated.
It was similar question before: A fix for AudioSessionInitialize Deprecated? but... it has no any mention about how to get initialization error status.
And of course, i know how to initialize audio session without this function: Just calling [AVAudioSession sharedInstance] cause hidden call of AudioSessionInitialize. But it returns non zero value anyway. So new interface does not allow to get initialization error status.
upd: I'm not sure it's important but i receive message to stdout (which i redirected to log file) while call with error happens:
ERROR: [7971] 146: Unable to talk to server: error 0x10000003
(268435459)
explaination why i need this:
It happens very rarely (less then 0,1% of case) but it happens for any firmware. Last case registered for iOS 7.0.3 - so it's actual return value still (btw, first case registered for first firmware my app supported: iOS 2.2). It's important feature (cause i develop alarm clock) - it allows to know user about issues in the evening and not in the morning (cause in the morning this issue will cause oversleep).
Is it possible to handle a request timeout with a UIAlert? I would like to inform the user that there has been a time out. I set 0.0 just for testing to see if it would occur. The log does not print out so i do not believe i am handling correcting
request.timeoutInterval=0.0;
and to handle it:
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
if(error.code == NSURLErrorTimedOut){
NSLog(#"Time out");
}
}
I am using NSURLConnectionDelegate and NSURLConnectionDownloadDelegate
Thanks.
You can find a list of all the relevant error codes here. Note that -1009 is kCFURLErrorNotConnectedToInternet. To force a timeout, you need to have the ability to suppress the actual sending of the URL, or find one that just goes into a black hole.
Apple bundles Network Link Conditioner with Xcode (its in the networking tools I believe). There is a great article on this tool on NSHipster.
Another way (I believe) to get a timeout is to immediately after sending a request is to switch to another app, putting yours in the background. Wait 5 minutes, switch back, and look at the log. What you can do is in a demo app continually send out NSURLConnections - that is, once the first returns, send another. so there is always one outstanding. Now switch your app out - switch to another app in the simulator - wait, then return. You should be able to catch the condition this way, you can see the affect of changing the timeoutinterval value.
There was a long thread about timeouts in the private Apple forums for iOS networking - you may be able to find it. In the end, the system enforces a reasonably long minimum (as I recall), and you may be able to make it longer but not shorter. This hidden behavior has for sure baffled many people. The responder to the question was Quinn "The Eskimo", one of Apple's most experienced networking engineers.
This question is going to be quite generic since I'm novice in iOS, video-streaming, and Bluetooth (going to be an interesting project).
Basically I wish to be able to stream low-res video from one iOS device to another iOS device, either through WiFi or Bluetooth depending on which one is available. Bonjour is used for initial service discovery. (I know streaming video over Bluetooth is non-ideal but it's one of the project's requirements)
So the question is what video-streaming framework/library can be used in order to maximize the amount of code shared between streaming video over WiFi and streaming video over Bluetooth.
Here are the instructions to test video streaming through Multipeer Conectivity:
You need Cocoapods, if you have not installed it yet, go to http://cocoapods.org/#install
Clone the transmitter from https://github.com/pj4533/AVCaptureMultipeerVideoDataOutput
Navigate to AVCaptureMultipeerVideoDataOutput/Sample directory in the Terminal and execute pod install
Clone the receiver from https://github.com/pj4533/SGSMultipeerVideoMixer
Run the transmitter in a physical device, you will see the back camera on screen
Run one or more receivers in the simulator or physical devices, the image of the emitter should appear in the receivers.
NOTE: The Multipeer Connectivity requires iOS 7 and both devices should have either WiFi or Bluetooth activated, I have tested it successfully on WiFi, Bluetooth may be too slow.
I will suggest to use the MultipeerConnectivity framework.
Here are the few delegate methods provided by MCSessionDelegate
MCSessionDelegate <NSObject>
// Received a byte stream from remote peer
- (void)session:(MCSession *)session didReceiveStream:(NSInputStream *)stream withName:(NSString *)streamName fromPeer:(MCPeerID *)peerID;
// Start receiving a resource from remote peer
- (void)session:(MCSession *)session didStartReceivingResourceWithName:(NSString *)resourceName fromPeer:(MCPeerID *)peerID withProgress:(NSProgress *)progress;
// Finished receiving a resource from remote peer and saved the content in a temporary location - the app is responsible for moving the file to a permanent location within its sandbox
- (void)session:(MCSession *)session didFinishReceivingResourceWithName:(NSString *)resourceName fromPeer:(MCPeerID *)peerID atURL:(NSURL *)localURL withError:(NSError *)error;`
Try to read http://nshipster.com/multipeer-connectivity/
I wrote code that does just that; here's a video I made of my app streaming video from one device to another:
<iframe width="560" height="315" src="https://www.youtube.com/embed/mWyZ1z55chw?rel=0" frameborder="0" gesture="media" allow="encrypted-media" allowfullscreen></iframe>
The screen recorder (iOS 11.2) is causing the occasional stutter on the receiving end (it was recording video at the same time my app was displaying it).
Anyway, it uses whatever connection you have between devices (wireless, Bluetooth, smoke signals, etc.l, let me know and I'll get you started.
Can't see the video? https://youtu.be/mWyZ1z55chw