You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code is developed using Objective-C language.
Required XCode version 7.2 for XCODE70 and version 8.2 for XCODE80
3. Discover : Search devices around your mobile.
Pressing 'Cast' button in ActionBar, must start search API [ss start].
Populate device list by overriding onServiceFound() & onServiceLost() listeners.
Stop device discovery, by calling stop search API [ss stop].
4.Code Snippet with Examples:
Discover
//Inside TvSelectViewController.m file
ServiceSearch *ss;
NSArray *serviceArray;
NSMutableArray *serviceBLEArray;
Application *_app;
static DataManager* instance = nil;
@implementationDataManager
+(DataManager*)getInstance
{
if (instance == nil) {
@synchronized(self) {
instance = [[selfalloc]init];
}
}
return instance;
}
/* Start TV Discovery */
-(void)startSearch
ss = [Service search];
[ss start];
[ss startUsingBLE];
}
/** Method to update (add) new service (tv).* event recieved when service(tv) found on Network.*/
- (void)onServiceFound:(Service * __nonnull)service
{
serviceArray = [ss getServices];
[tvTableView reloadData];
}
/// The ServiceSearch will call this delegate method when a service is lost////// param service The lost service
- (void)onServiceLost:(Service * __nonnull)service
{
serviceArray = [ss getServices];
[tvTableView reloadData];
}
/* Stop TV Discovery */
-(void)stopSearch
{
[ss stop];
[ss stopUsingBLE];
}
Launch TV application
// Inside DataManager.m file
-(void)lunchApplicationToTv: (Service*)service
{
// NSString *url =@"1234"; // appId or app id on tv when installNSString *appID = @"YcKEdWMZve.MultiScreenPlayer";
NSString *channelId = @"com.samsung.MultiScreenPlayer";
NSLog(@"input: createApplication:(appId):%@ channelURI: %@ args: %@",appID, channelId, nil);
_app = [service createApplication:appID channelURI:channelId args:nil];
_app.delegate = self;
_app.connectionTimeout = 5.0f;
[selfnotify:USER_NOTIFICATION_CONNECTING];
[_app connect];
_connectedService = service;
}
/// Called when the Channel is connected////// \param client The Client that just connected to the Channel////// \param error An error info if any
- (void)onConnect:(ChannelClient * __nullable)client error:(NSError * __nullable)error
{
NSLog(@"onConnect: client: %@ error: %@",client, error);
if (error == nil) {
timerAppNotAnswerOfReady = [NSTimerscheduledTimerWithTimeInterval:18.0ftarget:selfselector:@selector(cannotCommunicateWithTvApp) userInfo:nilrepeats:NO];
}
}
/// Called when the Channel is disconnected////// \param client The Client that just disconnected from the Channel////// \param error An error info if any
- (void)onDisconnect:(ChannelClient * __nullable)client error:(NSError * __nullable)error
{
NSLog(@"onDisconnect:client: %@ error: %@", client, error);
[selfnotify:USER_NOTIFICATION_DISCONNECTED];
ViewController *vc = (ViewController *)self.mainViewController;
if (vc != nil) {
[vc viewStyleUpdateToTable];
self.isConnectedTvApp = NO;
}
}
/* Share Content on TV */
[[DataManager getInstance].app publishWithEvent:@"play"message:json];