Update app.py
Browse files
app.py
CHANGED
@@ -108,6 +108,7 @@ def main():
|
|
108 |
)
|
109 |
loopback_page = "Simple video and audio loopback (sendrecv)"
|
110 |
media_constraints_page = "Configure media constraints with loopback (sendrecv)"
|
|
|
111 |
app_mode = st.sidebar.selectbox(
|
112 |
"Choose the app mode",
|
113 |
[
|
@@ -120,6 +121,7 @@ def main():
|
|
120 |
audio_sendonly_page,
|
121 |
loopback_page,
|
122 |
media_constraints_page,
|
|
|
123 |
],
|
124 |
)
|
125 |
st.subheader(app_mode)
|
@@ -142,6 +144,8 @@ def main():
|
|
142 |
app_loopback()
|
143 |
elif app_mode == media_constraints_page:
|
144 |
app_media_constraints()
|
|
|
|
|
145 |
|
146 |
logger.debug("=== Alive threads ===")
|
147 |
for thread in threading.enumerate():
|
@@ -553,7 +557,7 @@ def app_streaming():
|
|
553 |
video_processor_factory=OpenCVVideoProcessor,
|
554 |
)
|
555 |
|
556 |
-
if webrtc_ctx.video_processor:
|
557 |
webrtc_ctx.video_processor.type = st.radio(
|
558 |
"Select transform type", ("noop", "cartoon", "edges", "rotate")
|
559 |
)
|
@@ -687,6 +691,18 @@ def app_media_constraints():
|
|
687 |
st.write(f"The frame rate is set as {frame_rate}")
|
688 |
|
689 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
690 |
if __name__ == "__main__":
|
691 |
import os
|
692 |
|
|
|
108 |
)
|
109 |
loopback_page = "Simple video and audio loopback (sendrecv)"
|
110 |
media_constraints_page = "Configure media constraints with loopback (sendrecv)"
|
111 |
+
programatically_control_page = "Control the playing state programatically"
|
112 |
app_mode = st.sidebar.selectbox(
|
113 |
"Choose the app mode",
|
114 |
[
|
|
|
121 |
audio_sendonly_page,
|
122 |
loopback_page,
|
123 |
media_constraints_page,
|
124 |
+
programatically_control_page,
|
125 |
],
|
126 |
)
|
127 |
st.subheader(app_mode)
|
|
|
144 |
app_loopback()
|
145 |
elif app_mode == media_constraints_page:
|
146 |
app_media_constraints()
|
147 |
+
elif app_mode == programatically_control_page:
|
148 |
+
app_programatically_play()
|
149 |
|
150 |
logger.debug("=== Alive threads ===")
|
151 |
for thread in threading.enumerate():
|
|
|
557 |
video_processor_factory=OpenCVVideoProcessor,
|
558 |
)
|
559 |
|
560 |
+
if media_file_info["type"] == "video" and webrtc_ctx.video_processor:
|
561 |
webrtc_ctx.video_processor.type = st.radio(
|
562 |
"Select transform type", ("noop", "cartoon", "edges", "rotate")
|
563 |
)
|
|
|
691 |
st.write(f"The frame rate is set as {frame_rate}")
|
692 |
|
693 |
|
694 |
+
def app_programatically_play():
|
695 |
+
""" A sample of controlling the playing state from Python. """
|
696 |
+
playing = st.checkbox("Playing", value=True)
|
697 |
+
|
698 |
+
webrtc_streamer(
|
699 |
+
key="media-constraints",
|
700 |
+
desired_playing_state=playing,
|
701 |
+
mode=WebRtcMode.SENDRECV,
|
702 |
+
client_settings=WEBRTC_CLIENT_SETTINGS,
|
703 |
+
)
|
704 |
+
|
705 |
+
|
706 |
if __name__ == "__main__":
|
707 |
import os
|
708 |
|