@@ -1641,47 +1641,43 @@ def __init__(
1641
1641
app_version = app_version
1642
1642
)
1643
1643
1644
+ def mute_all (self ,
1645
+ session_id : str ,
1646
+ excludedStreamIds : Optional [List [str ]],
1647
+ active : bool = True ,
1648
+ options : dict = {}) -> requests .Response :
1644
1649
1645
-
1646
- def mute (self ,
1647
- session_id : str ,
1648
- excludedStreamIds : Optional [List [str ]],
1649
- stream_id : str = "" ,
1650
- active : bool = True ,
1651
- data : dict = {}) -> requests .Response :
1652
1650
"""
1653
- Use this method so the moderator can mute all streams or a specific stream for OpenTok.
1654
- Please note that a client is able to unmute themselves.
1651
+ Use this method so the moderator can mute all streams for OpenTok.
1652
+
1653
+ A moderator can exclude streams Id's from being muted. Please note that a
1654
+ client is able to unmute themselves.
1655
+
1655
1656
This function stays in the OpenTok class and inherits from the Client class.
1656
1657
1657
- :param session_id gets the session id from another function called get_session()
1658
+ :param session_id gets the session id
1658
1659
1659
- :param excludedStreamIds is a list of The stream IDs for streams that should not be muted.
1660
+ :param excludedStreamIds is a list of the stream IDs for streams that should not be muted.
1660
1661
This is an optional property. If you omit this property, all streams in the session will be muted.
1661
1662
1662
- :param stream_id gets the stream id from another function called get_stream(). Note
1663
- that this variable is set to an empty string in the function definition as a specific
1664
- stream may not be chosen.
1665
-
1666
1663
:param active is a required boolean that determines whether streams published after the
1667
1664
call, in addition to the current streams in the session, should be muted (True) or not (False).
1668
-
1665
+
1666
+ :param options is an empty dictonary representing the payload of the request,
1667
+ whose contents will get populated inside the function
1669
1668
"""
1670
-
1669
+
1670
+ url = self .endpoints .get_mute_all_url (session_id )
1671
+
1671
1672
try :
1672
- if not stream_id :
1673
- url = self .endpoints .get_mute_all_url (session_id )
1673
+ if excludedStreamIds :
1674
1674
if active :
1675
- data = {'active' : active , 'excludedStreams' : excludedStreamIds }
1676
- else :
1677
- active = False
1678
- data = {'active' : active , 'excludedStreams' : []}
1675
+ options = {'active' : active , 'excludedStreams' : excludedStreamIds }
1679
1676
else :
1680
- url = self .endpoints .get_stream_url (session_id , stream_id ) + "/mute"
1681
- data = None
1682
-
1683
-
1684
- response = requests .post (url , headers = self .get_headers (), data = json .dumps (data ))
1677
+ active = False
1678
+ options = {'active' : active , 'excludedStreams' : []}
1679
+
1680
+ response = requests .post (url , headers = self .get_headers (), data = json .dumps (options ))
1685
1681
1686
1682
if response :
1687
1683
return response
@@ -1693,9 +1689,44 @@ def mute(self,
1693
1689
raise NotFoundError ("Mute not found" )
1694
1690
except Exception as e :
1695
1691
raise OpenTokException (
1696
- ("There was an error thrown by the OpenTok SDK, please check that your session_id {0} and stream_id (if exists) {1} are valid" ).format (
1692
+ ("There was an error thrown by the OpenTok SDK, please check that your session_id {0} and excludedStreamIds (if exists) {1} are valid" ).format (
1693
+ session_id , excludedStreamIds ))
1694
+
1695
+
1696
+
1697
+ def mute_stream (self , session_id : str , stream_id : str , options : dict = {}) -> requests .Response :
1698
+ """
1699
+ Use this method so the moderator can mute a single stream for OpenTok.
1700
+ This function stays in the OpenTok class and inherits from the Client class.
1701
+
1702
+ :param session_id gets the session id from another function called get_session()
1703
+
1704
+ :param stream_id gets a single stream id
1705
+
1706
+ :param options is an empty dictonary representing the payload of the request,
1707
+ whose contents will get populated inside the function
1708
+ """
1709
+
1710
+ try :
1711
+ if stream_id :
1712
+ url = self .endpoints .get_stream_url (session_id , stream_id ) + "/mute"
1713
+
1714
+ response = requests .post (url , headers = self .get_headers (), data = json .dumps (options ))
1715
+
1716
+ if response :
1717
+ return response
1718
+ elif response .status_code == 400 :
1719
+ raise GetStreamError ("Invalid request. This response may indicate that data in your request data is invalid JSON. Or it may indicate that you do not pass in a session ID or you passed in an invalid stream ID." )
1720
+ elif response .status_code == 403 :
1721
+ raise AuthError ("Failed to create session, invalid credentials" )
1722
+ elif response .status_code == 404 :
1723
+ raise NotFoundError ("Mute not found" )
1724
+ except Exception as e :
1725
+ raise OpenTokException (
1726
+ ("There was an error thrown by the OpenTok SDK, please check that your session_id {0} and stream_id {1} are valid" ).format (
1697
1727
session_id , stream_id ))
1698
1728
1729
+
1699
1730
def play_dtmf (self , session_id : str , connection_id : str , digits : str , options : dict = {}) -> requests .Response :
1700
1731
"""
1701
1732
Plays a DTMF string into a session or to a specific connection
0 commit comments