From: Dawid Juszczak Date: Tue, 20 Aug 2019 14:19:05 +0000 (+0200) Subject: [fix][mediacontroller] add callIfPossible to listeners X-Git-Tag: accepted/tizen/unified/20190920.065316~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F57%2F212357%2F1;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [fix][mediacontroller] add callIfPossible to listeners This commit adds callIfPossible functions to listeners to avoid calling not set callbacks. Change-Id: I91b36177eac0286d644fd298d9ad253e3586badb Signed-off-by: Dawid Juszczak --- diff --git a/src/mediacontroller/mediacontroller_api.js b/src/mediacontroller/mediacontroller_api.js index aef8c56..f682337 100755 --- a/src/mediacontroller/mediacontroller_api.js +++ b/src/mediacontroller/mediacontroller_api.js @@ -198,7 +198,7 @@ var ServerInfoStatusListener = new ListenerManager( native_, '_ServerInfoStatusListener', function(msg, listener) { - listener(msg.state); + native_.callIfPossible(listener, msg.state); } ); @@ -207,23 +207,23 @@ var ServerInfoPlaybackInfoListener = new ListenerManager( '_ServerInfoPlaybackInfoListener', function(msg, listener) { if (msg.action === 'onplaybackchanged') { - listener[msg.action](msg.state, msg.position); + native_.callIfPossible(listener[msg.action], msg.state, msg.position); } if (msg.action === 'onshufflemodechanged') { - listener[msg.action](msg.mode); + native_.callIfPossible(listener[msg.action], msg.mode); } if (msg.action === 'onrepeatmodechanged') { utils_.printDeprecationWarningFor( 'onrepeatmodechanged', 'onrepeatstatechanged' ); - listener[msg.action](msg.mode); + native_.callIfPossible(listener[msg.action], msg.mode); } if (msg.action === 'onrepeatstatechanged') { - listener[msg.action](msg.state); + native_.callIfPossible(listener[msg.action], msg.state); } if (msg.action === 'onmetadatachanged') { - listener[msg.action](new MediaControllerMetadata(msg.metadata)); + native_.callIfPossible(listener[msg.action], new MediaControllerMetadata(msg.metadata)); } } ); @@ -233,10 +233,10 @@ var ServerInfoPlaylistUpdatedListener = new ListenerManager( '_ServerInfoPlaylistUpdatedListener', function(msg, listener) { if (msg.action === 'onplaylistupdated') { - listener[msg.action](msg.serverName, new MediaControllerPlaylist(msg)); + native_.callIfPossible(listener[msg.action], msg.serverName, new MediaControllerPlaylist(msg)); } if (msg.action === 'onplaylistdeleted') { - listener[msg.action](msg.serverName, msg.name); + native_.callIfPossible(listener[msg.action], msg.serverName, msg.name); } } );