video
To upload files, please first save the app
import streamlit as st
st.title("Video Player App")
st.markdown("### Upload and Play Videos")
# File uploader for video files
uploaded_file = st.file_uploader(
"Choose a video file",
type=['mp4', 'mov', 'avi', 'mkv', 'webm']
)
if uploaded_file is not None:
st.video(uploaded_file)
# Display file details
st.write(f"**File name:** {uploaded_file.name}")
st.write(f"**File size:** {uploaded_file.size} bytes")
st.markdown("### Or Enter a Video URL")
# URL input for videos
video_url = st.text_input("Enter video URL (including YouTube):")
if video_url:
try:
st.video(video_url)
except Exception as e:
st.error(f"Error loading video: {str(e)}")
st.markdown("### Sample Videos")
# Some sample video URLs
sample_videos = {
"Big Buck Bunny": "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
"Elephant Dream": "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4"
}
selected_sample = st.selectbox("Choose a sample video:", ["None"] + list(sample_videos.keys()))
if selected_sample != "None":
st.video(sample_videos[selected_sample])
st.markdown("### Video Player Features")
st.markdown("""
- Upload your own video files (MP4, MOV, AVI, MKV, WebM)
- Play videos from URLs (including YouTube)
- Built-in video controls (play, pause, volume, fullscreen)
- Automatic format detection
""")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?