UNPKG

spectatr-player-sdk

Version:

A custom video player built with Stencil with Shaka Player integration

644 lines (566 loc) 11.1 kB
:host { display: flex; flex-direction: column; flex: 1; position: relative; width: 100%; height: 100%; overflow: auto; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; } .scheduled-message { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; background-color: rgba(0, 0, 0, 0.7); color: white; font-size: 1.5rem; z-index: 10; } .video-container { position: relative; width: 100%; height: 0; /* Key for aspect ratio */ padding-bottom: 56.25%; /* 16:9 aspect ratio (9/16*100) */ background: #000; border-radius: 10px; border: none; overflow: hidden; } .video-container video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: contain; /* or 'cover' based on need */ } .loading-spinner { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 100; } .spinner { width: 40px; height: 40px; border: 4px solid var(--vp-controls-bg); border-radius: 50%; border-top: 4px solid var(--vp-accent); animation: spin 1s linear infinite; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } .controls { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(transparent, rgba(0, 0, 0, 0.8)); padding: 10px 10px 20px; opacity: 0; transition: opacity 0.3s ease; z-index: 100; } .controls.visible { opacity: 1; } .controls-row { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; } .control-btn { background: none; border: none; color: white; cursor: pointer; padding: 8px; border-radius: 4px; transition: background-color 0.2s; display: flex; align-items: center; justify-content: center; } .go-live-button { background: var(--vp-accent); color: var(--vp-video-text); border-radius: 10px; } .control-btn:hover { background: rgba(255, 255, 255, 0.2); color: white; } .time-display { color: var(--vp-video-text); font-size: 14px; white-space: nowrap; } .spacer { flex: 1; } .volume-control { display: flex; align-items: center; gap: 10px; } .volume-slider { width: 0; opacity: 0; transition: all 0.2s ease; height: 4px; background: rgba(255, 255, 255, 0.3); border-radius: 2px; outline: none; -webkit-appearance: none; } .volume-control:hover .volume-slider { width: 70px; /* Adjust as needed */ opacity: 1; } .volume-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 10px; height: 10px; background: var(--vp-accent); border-radius: 50%; cursor: pointer; } .volume-slider::-moz-range-thumb { width: 10px; height: 10px; background: var(--vp-accent); border-radius: 50%; cursor: pointer; border: none; } /* Add to your video-player.css */ .progress-container { position: relative; width: 100%; height: 4px; } .progress-slider { position: absolute; width: 100%; height: 5.5px; -webkit-appearance: none; appearance: none; background: transparent; z-index: 2; cursor: pointer; } .progress-slider::-webkit-slider-thumb { /* -webkit-appearance: none; appearance: none; width: 8px; height: 8px; border-radius: 50%; background: #e95b5b; cursor: pointer; */ opacity: 0; /* transition: opacity 0.2s; */ } /* .progress-slider:hover::-webkit-slider-thumb { opacity: 1; } */ .buffering-bar { position: absolute; height: 4px; background: var(--vp-accent, '#e95b5b'); top: 0; left: 0; z-index: 1; } .timeline-markers { position: absolute; top: 50%; left: 0; width: 100%; height: 100%; pointer-events: none; } .timeline-marker { position: absolute; /* width: 4px; height: 4px; background: #ff5722; */ transform: translate(-50%, -50%); top: 50%; margin-top: -1.25px; z-index: 2; cursor: pointer; pointer-events: auto; } .timeline-marker::before { content: attr(data-tooltip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: rgba(0, 0, 0, 0.8); color: white; padding: 4px 8px; border-radius: 4px; font-size: 12px; white-space: nowrap; opacity: 0; transition: opacity 0.2s ease; margin-bottom: 5px; } .timeline-marker:hover::before { opacity: 1; } .settings-menu { position: absolute; pointer-events: auto; bottom: 80px; right: 16px; background: rgba(28, 28, 28, 0.9); border-radius: 12px; padding: 8px 0; width: 240px; max-height: 60vh; overflow-y: auto; z-index: 20; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5); backdrop-filter: blur(16px); } .main-settings { display: flex; flex-direction: column; } .settings-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; color: white; background: transparent; border: none; width: 100%; text-align: left; cursor: pointer; font-size: 14px; } .settings-item:hover { background: rgba(255, 255, 255, 0.1); } .selected-option { color: #aaa; font-size: 13px; } .options-panel { display: flex; flex-direction: column; } .back-button { display: flex; align-items: center; padding: 10px 16px; color: white; background: transparent; border: none; width: 100%; text-align: left; cursor: pointer; font-size: 14px; gap: 8px; } .back-button svg { width: 18px; height: 18px; } .options-list { padding: 8px 0; } .option-item { display: block; padding: 8px 16px 8px 40px; color: white; background: transparent; border: none; width: 100%; text-align: left; cursor: pointer; font-size: 14px; } .option-item:hover { background: rgba(255, 255, 255, 0.1); } .option-item.active { color: var(--vp-accent); font-weight: 500; } /* .settings-section { margin-bottom: 15px; } .settings-section:last-child { margin-bottom: 0; } .settings-section h4 { color: white; margin: 0 0 10px 0; font-size: 14px; font-weight: 600; } .settings-option { display: block; width: 100%; background: none; border: none; color: white; padding: 8px 12px; text-align: left; cursor: pointer; border-radius: 4px; margin-bottom: 5px; transition: background-color 0.2s; } .settings-option:hover { background: rgba(255, 255, 255, 0.1); } .settings-option.active { background: #007bff; } */ .live-tag { position: absolute; bottom: 0; left: 0; z-index: 10; margin: 16px; font-size: 0.8rem; padding: 4px 8px; font-weight: bold; letter-spacing: 1px; border: 1px solid #ff0000; color: #ff0000; border-radius: 4px; background-color: rgba(255, 0, 0, 0.1); display: flex; align-items: center; gap: 6px; } .live-tag::before { content: ''; display: block; width: 8px; height: 8px; background-color: #ff0000; border-radius: 50%; animation: pulse 1.5s infinite; } @keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.2; } 100% { opacity: 1; } } @media (max-width: 768px) { .controls { padding: 20px 15px 15px; } .controls-row { gap: 10px; } .volume-control { display: none; } } .center-controls { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; pointer-events: none; z-index: 2; opacity: 0; transition: opacity 0.3s ease; } .center-controls.visible { opacity: 1; } .center-controls .controls-container { display: flex; align-items: center; gap: 30px; pointer-events: auto; } .big-play-pause { width: 80px; height: 80px; background: var(--vp-controls-bg); border-radius: 50%; border: none; display: flex; justify-content: center; align-items: center; cursor: pointer; transition: transform 0.2s ease; outline: none; } .big-play-pause:hover { transform: scale(1.1); } .skip-btn { width: 50px; height: 50px; background: transparent; border-radius: 50%; border: none; display: flex; justify-content: center; align-items: center; cursor: pointer; transition: transform 0.2s ease; } .skip-btn:hover { transform: scale(1.1); } .buffering-loader { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 3; display: none; } .buffering-loader.active { display: block; } @keyframes slideIn { to { transform: translateX(0); opacity: 1; } } @keyframes fadeOut { to { opacity: 0; } } .video-info { padding: 8px 2px; background: transparent; } .title-like-container { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; } .rating-container { display: flex; align-items: center; margin-left: auto; background: var(--vp-video-text); border-radius: 4px; padding: 4px 8px; } .rating-container .divider { width: 2px; height: 16px; background: var(--vp-controls-bg); margin: 0% 8px; } .thumb-btn { background: none; border: none; cursor: pointer; display: flex; align-items: center; gap: 4px; color: #606060; outline: none; } .thumb-btn.active { color: var(--vp-accent); } .count { font-size: 14px; color: #606060; font-weight: 500; } .video-title { font-size: 1.6rem; font-weight: bold; margin: 0%; color: var(--vp-text); font-family: var(--title-font); } .description-container { background: #f9f9f9; /* YouTube-like light gray */ border-radius: 8px; padding: 12px 16px; margin-top: 8px; font-family: var(--description-font); } .video-metadata { color: #606060; /* YouTube's metadata color */ font-size: 0.9rem; margin-bottom: 8px; display: flex; align-items: center; } .divider { margin: 0 4px; } .video-description { margin: 0; font-size: 0.9rem; line-height: 1.5; color: var(--video-description-color, #666); transition: all 0.3s ease; } .video-description.truncated { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; } .show-more-btn { background: none; border: none; color: var(--accent-color, #0066cc); font-size: 0.8rem; cursor: pointer; padding: 4px 0; margin-top: 4px; display: inline-block; outline: none; } .show-more-btn:hover { text-decoration: underline; } /* Mobile responsiveness */ @media (max-width: 768px) { .video-info { padding: 4px 2px; } .video-title { font-size: 1.2rem; } }