forked from streamlit/streamlit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for playing from URL in Audio and Video objects (streamlit#423)
* added conditional on element("url") * added url as 4 to Audio and Video protobuf definitions * Audio element: URL now checked and passed through * getting audio element +url testing correctly * added a URL selector with samples to the Audio example script * JS now displays Audio element w/ URL as an audio player * removed .swp file * url positive and negative test cases working for Audio URL * 3 audio samples from Helix autogenerated music * added support for URL in frontend Video element * added support for play-from-URL to Video element * ogg, mp4, and webm formats all represented in the video example. * added tests for URL in Video element * make examples in selector look nicer * linted and whatnot * show YouTube links in iFrame * video examples with 3 different styles of youtube link * conditionals and regex to handle YouTube links in Video elements * tests for youtube links added. * audio Ref packed into tag * updated docstrings per Thiago * oneof url/data switch in Audio and Video protobufs * added Type to Video proto to support switch on iframe + video tags * refactored Audio + Video protobuf handling (WIP) * test for Video.Type.YOUTUBE_IFRAME in python and JS * formatting * fixing bug preventing audio format + start_time from propagating * fixing py2 bug where testing for type(data) in six.string_types fails * py2/3 compat fix * updated tests for changes in DeltaGenerator.py / media_proto.py * tests for Python2 and Python3 behavior * formatting * minor doc tweak * adding back Audio.tsx react components * docstring formatting * regex moved to global, refomatted (per Thiago) * docstring formatting
- Loading branch information
Showing
10 changed files
with
358 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2018-2019 Streamlit Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import streamlit as st | ||
|
||
st.title("Play Videos from URLs") | ||
|
||
st.write("st.video allows a variety of HTML5 supported video links, including YouTube.") | ||
|
||
|
||
def shorten_vid_option(opt): | ||
return opt.split("/")[-1] | ||
|
||
|
||
# A random sampling of videos found around the web. We should replace | ||
# these with those sourced from the streamlit community if possible! | ||
vidurl = st.selectbox( | ||
"Pick a video to play", | ||
( | ||
"https://youtu.be/_T8LGqJtuGc", | ||
"https://www.youtube.com/watch?v=kmfC-i9WgH0", | ||
"https://www.youtube.com/embed/sSn4e1lLVpA", | ||
"http://www.rochikahn.com/video/videos/zapatillas.mp4", | ||
"http://www.marmosetcare.com/video/in-the-wild/intro.webm", | ||
"https://www.orthopedicone.com/u/home-vid-4.mp4", | ||
), | ||
0, | ||
shorten_vid_option, | ||
) | ||
|
||
st.video(vidurl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.