Skip to content

cast

IssueUpdated dataclass

This is fired whenever the outstanding issue/error message changes. issueMessage is empty if there is no issue.

Source code in zendriver/cdp/cast.py
@event_class("Cast.issueUpdated")
@dataclass
class IssueUpdated:
    """
    This is fired whenever the outstanding issue/error message changes.
    ``issueMessage`` is empty if there is no issue.
    """

    issue_message: str

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> IssueUpdated:
        return cls(issue_message=str(json["issueMessage"]))

issue_message: str instance-attribute

__init__(issue_message)

from_json(json) classmethod

Source code in zendriver/cdp/cast.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> IssueUpdated:
    return cls(issue_message=str(json["issueMessage"]))

Sink dataclass

Source code in zendriver/cdp/cast.py
@dataclass
class Sink:
    name: str

    id_: str

    #: Text describing the current session. Present only if there is an active
    #: session on the sink.
    session: typing.Optional[str] = None

    def to_json(self) -> T_JSON_DICT:
        json: T_JSON_DICT = dict()
        json["name"] = self.name
        json["id"] = self.id_
        if self.session is not None:
            json["session"] = self.session
        return json

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> Sink:
        return cls(
            name=str(json["name"]),
            id_=str(json["id"]),
            session=str(json["session"])
            if json.get("session", None) is not None
            else None,
        )

id_: str instance-attribute

name: str instance-attribute

session: typing.Optional[str] = None class-attribute instance-attribute

__init__(name, id_, session=None)

from_json(json) classmethod

Source code in zendriver/cdp/cast.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> Sink:
    return cls(
        name=str(json["name"]),
        id_=str(json["id"]),
        session=str(json["session"])
        if json.get("session", None) is not None
        else None,
    )

to_json()

Source code in zendriver/cdp/cast.py
def to_json(self) -> T_JSON_DICT:
    json: T_JSON_DICT = dict()
    json["name"] = self.name
    json["id"] = self.id_
    if self.session is not None:
        json["session"] = self.session
    return json

SinksUpdated dataclass

This is fired whenever the list of available sinks changes. A sink is a device or a software surface that you can cast to.

Source code in zendriver/cdp/cast.py
@event_class("Cast.sinksUpdated")
@dataclass
class SinksUpdated:
    """
    This is fired whenever the list of available sinks changes. A sink is a
    device or a software surface that you can cast to.
    """

    sinks: typing.List[Sink]

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> SinksUpdated:
        return cls(sinks=[Sink.from_json(i) for i in json["sinks"]])

sinks: typing.List[Sink] instance-attribute

__init__(sinks)

from_json(json) classmethod

Source code in zendriver/cdp/cast.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> SinksUpdated:
    return cls(sinks=[Sink.from_json(i) for i in json["sinks"]])

disable()

Stops observing for sinks and issues.

Source code in zendriver/cdp/cast.py
def disable() -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    Stops observing for sinks and issues.
    """
    cmd_dict: T_JSON_DICT = {
        "method": "Cast.disable",
    }
    json = yield cmd_dict

enable(presentation_url=None)

Starts observing for sinks that can be used for tab mirroring, and if set, sinks compatible with presentationUrl as well. When sinks are found, a sinksUpdated event is fired. Also starts observing for issue messages. When an issue is added or removed, an issueUpdated event is fired.

Parameters:

Name Type Description Default
presentation_url Optional[str]

(Optional)

None
Source code in zendriver/cdp/cast.py
def enable(
    presentation_url: typing.Optional[str] = None,
) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    Starts observing for sinks that can be used for tab mirroring, and if set,
    sinks compatible with ``presentationUrl`` as well. When sinks are found, a
    ``sinksUpdated`` event is fired.
    Also starts observing for issue messages. When an issue is added or removed,
    an ``issueUpdated`` event is fired.

    :param presentation_url: *(Optional)*
    """
    params: T_JSON_DICT = dict()
    if presentation_url is not None:
        params["presentationUrl"] = presentation_url
    cmd_dict: T_JSON_DICT = {
        "method": "Cast.enable",
        "params": params,
    }
    json = yield cmd_dict

set_sink_to_use(sink_name)

Sets a sink to be used when the web page requests the browser to choose a sink via Presentation API, Remote Playback API, or Cast SDK.

Parameters:

Name Type Description Default
sink_name str
required
Source code in zendriver/cdp/cast.py
def set_sink_to_use(sink_name: str) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    Sets a sink to be used when the web page requests the browser to choose a
    sink via Presentation API, Remote Playback API, or Cast SDK.

    :param sink_name:
    """
    params: T_JSON_DICT = dict()
    params["sinkName"] = sink_name
    cmd_dict: T_JSON_DICT = {
        "method": "Cast.setSinkToUse",
        "params": params,
    }
    json = yield cmd_dict

start_desktop_mirroring(sink_name)

Starts mirroring the desktop to the sink.

Parameters:

Name Type Description Default
sink_name str
required
Source code in zendriver/cdp/cast.py
def start_desktop_mirroring(
    sink_name: str,
) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    Starts mirroring the desktop to the sink.

    :param sink_name:
    """
    params: T_JSON_DICT = dict()
    params["sinkName"] = sink_name
    cmd_dict: T_JSON_DICT = {
        "method": "Cast.startDesktopMirroring",
        "params": params,
    }
    json = yield cmd_dict

start_tab_mirroring(sink_name)

Starts mirroring the tab to the sink.

Parameters:

Name Type Description Default
sink_name str
required
Source code in zendriver/cdp/cast.py
def start_tab_mirroring(
    sink_name: str,
) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    Starts mirroring the tab to the sink.

    :param sink_name:
    """
    params: T_JSON_DICT = dict()
    params["sinkName"] = sink_name
    cmd_dict: T_JSON_DICT = {
        "method": "Cast.startTabMirroring",
        "params": params,
    }
    json = yield cmd_dict

stop_casting(sink_name)

Stops the active Cast session on the sink.

Parameters:

Name Type Description Default
sink_name str
required
Source code in zendriver/cdp/cast.py
def stop_casting(sink_name: str) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    Stops the active Cast session on the sink.

    :param sink_name:
    """
    params: T_JSON_DICT = dict()
    params["sinkName"] = sink_name
    cmd_dict: T_JSON_DICT = {
        "method": "Cast.stopCasting",
        "params": params,
    }
    json = yield cmd_dict