Fix video test page: Remove web player modal and fix Qt player file paths

- Removed web video player modal from video test page
- Updated instructions to clarify videos play in Qt player window
- Changed button text to 'Play in Qt Player' for clarity
- Added warning alert explaining Qt player window usage
- Enhanced success message to guide users to Qt player window
- Fixed Qt player file path handling for relative paths from uploads directory
- Added file existence verification before attempting to play video
- Improved error handling for missing video files with overlay display

Videos uploaded through web interface now properly play in Qt player window instead of web browser.
parent 11265546
......@@ -792,7 +792,36 @@ class PlayerWindow(QMainWindow):
"""Play video file with optional overlay data"""
try:
with QMutexLocker(self.mutex):
url = QUrl.fromLocalFile(str(Path(file_path).absolute()))
# Handle both absolute and relative file paths
path_obj = Path(file_path)
if not path_obj.is_absolute():
# For relative paths, resolve them relative to the application directory
import os
app_dir = Path(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
absolute_path = app_dir / file_path
logger.debug(f"Resolving relative path '{file_path}' to '{absolute_path}'")
else:
absolute_path = path_obj
# Verify file exists before trying to play
if not absolute_path.exists():
logger.error(f"Video file not found: {absolute_path}")
# Show error in overlay
overlay_view = self.video_widget.get_overlay_view()
error_data = {
'title': 'File Not Found',
'subtitle': f'Cannot find: {file_path}',
'ticker': 'Please check the file path and try again.'
}
if hasattr(overlay_view, 'overlay_channel') and overlay_view.overlay_channel:
if self._is_webengine_ready(overlay_view):
overlay_view.update_overlay_data(error_data)
else:
overlay_view.update_overlay_data(error_data)
return
url = QUrl.fromLocalFile(str(absolute_path))
logger.info(f"Loading video URL: {url.toString()}")
self.media_player.setSource(url)
# Update overlay with video info using safe method
......
......@@ -72,13 +72,17 @@
<li>Select a video file to upload</li>
<li>Choose an overlay template</li>
<li>Click "Upload Video" to start upload</li>
<li>After upload, click "Play" to view the video</li>
<li><strong>After upload, click "Play in Qt Player" to view the video in the Qt player window</strong></li>
<li>Use "Delete" to remove uploaded videos</li>
</ol>
<div class="alert alert-info">
<i class="fas fa-lightbulb me-2"></i>
Videos are stored temporarily and will be deleted when the application restarts.
</div>
<div class="alert alert-warning">
<i class="fas fa-desktop me-2"></i>
<strong>Note:</strong> Videos play in the Qt player window, not in the web browser. Make sure the Qt player window is visible.
</div>
</div>
</div>
......@@ -105,27 +109,6 @@
</div>
</div>
<!-- Video Player Modal -->
<div class="modal fade" id="videoPlayerModal" tabindex="-1">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Video Player</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<div id="video-player-container" style="position: relative; width: 100%; height: 0; padding-bottom: 56.25%;">
<video id="video-player" controls style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;">
Your browser does not support the video tag.
</video>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
......@@ -143,7 +126,6 @@ document.addEventListener('DOMContentLoaded', function() {
const playerStatus = document.getElementById('player-status');
const currentVideo = document.getElementById('current-video');
const refreshStatusBtn = document.getElementById('refresh-status');
const videoPlayer = document.getElementById('video-player');
// Store uploaded videos
let uploadedVideos = [];
......@@ -252,7 +234,7 @@ document.addEventListener('DOMContentLoaded', function() {
</div>
<div>
<button class="btn btn-sm btn-success play-btn me-2" data-filename="${filename}" data-template="${template}">
<i class="fas fa-play me-1"></i>Play
<i class="fas fa-desktop me-1"></i>Play in Qt Player
</button>
<button class="btn btn-sm btn-danger delete-btn" data-id="${videoId}" data-filename="${filename}">
<i class="fas fa-trash me-1"></i>Delete
......@@ -299,15 +281,29 @@ document.addEventListener('DOMContentLoaded', function() {
.then(response => response.json())
.then(data => {
if (data.success) {
// Show player modal
new bootstrap.Modal(document.getElementById('videoPlayerModal')).show();
// Update player status
playerStatus.className = 'badge bg-success';
playerStatus.textContent = 'Playing';
currentVideo.textContent = filename.split('/').pop();
// Show success message
const alertDiv = document.createElement('div');
alertDiv.className = 'alert alert-success alert-dismissible fade show mt-3';
alertDiv.innerHTML = `
<i class="fas fa-check-circle me-2"></i>
Video sent to Qt Player window! Check the Qt player window to view the video.
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
`;
e.target.closest('.card-body').appendChild(alertDiv);
// Auto-dismiss after 5 seconds
setTimeout(() => {
if (alertDiv.parentNode) {
alertDiv.remove();
}
}, 5000);
} else {
alert('Failed to play video: ' + (data.error || 'Unknown error'));
alert('Failed to send video to Qt Player: ' + (data.error || 'Unknown error'));
}
})
.catch(error => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment