|
1 | 1 | from datetime import datetime # generate_token
|
| 2 | +from typing import List, Optional # imports List, Optional type hint |
2 | 3 | import calendar # generate_token
|
3 | 4 | import base64 # generate_token
|
4 | 5 | import random # generate_token
|
@@ -1423,30 +1424,45 @@ def __init__(
|
1423 | 1424 |
|
1424 | 1425 |
|
1425 | 1426 |
|
1426 |
| - def mute(self, session_id: str, stream_id: str= "", options: dict = {}) -> requests.Response: |
| 1427 | + def mute(self, |
| 1428 | + session_id: str, |
| 1429 | + excludedStreamIds: Optional[List[str]], |
| 1430 | + stream_id: str= "", |
| 1431 | + active: bool= True, |
| 1432 | + data: dict = {}) -> requests.Response: |
1427 | 1433 | """
|
1428 | 1434 | Use this method so the moderator can mute all streams or a specific stream for OpenTok.
|
1429 | 1435 | Please note that a client is able to unmute themselves.
|
1430 | 1436 | This function stays in the OpenTok class and inherits from the Client class.
|
1431 | 1437 |
|
1432 | 1438 | :param session_id gets the session id from another function called get_session()
|
1433 | 1439 |
|
| 1440 | + :param excludedStreamIds is a list of The stream IDs for streams that should not be muted. |
| 1441 | + This is an optional property. If you omit this property, all streams in the session will be muted. |
| 1442 | +
|
1434 | 1443 | :param stream_id gets the stream id from another function called get_stream(). Note
|
1435 | 1444 | that this variable is set to an empty string in the function definition as a specific
|
1436 | 1445 | stream may not be chosen.
|
| 1446 | +
|
| 1447 | + :param active is a required boolean that determines whether streams published after the |
| 1448 | + call, in addition to the current streams in the session, should be muted (True) or not (False). |
1437 | 1449 |
|
1438 | 1450 | """
|
1439 |
| - |
| 1451 | + |
1440 | 1452 | try:
|
1441 | 1453 | if not stream_id:
|
1442 | 1454 | url = self.endpoints.get_mute_all_url(session_id)
|
1443 |
| - data = {'excludedStream': stream_id} |
| 1455 | + if active: |
| 1456 | + data = {'active': active, 'excludedStreams': excludedStreamIds } |
| 1457 | + else: |
| 1458 | + active = False |
| 1459 | + data = {'active': active, 'excludedStreams': []} |
1444 | 1460 | else:
|
1445 | 1461 | url = self.endpoints.get_stream_url(session_id, stream_id) + "/mute"
|
1446 | 1462 | data = None
|
1447 | 1463 |
|
1448 | 1464 |
|
1449 |
| - response = requests.post(url, headers=self.get_headers(), data=data) |
| 1465 | + response = requests.post(url, headers=self.get_headers(), data=json.dumps(data)) |
1450 | 1466 |
|
1451 | 1467 | if response:
|
1452 | 1468 | return response
|
|
0 commit comments