Skip to content

Commit 77e2dac

Browse files
authored
Merge pull request #153 from hotosm/develop
Fix for media player, embedded media
2 parents b03305a + 3f6dca0 commit 77e2dac

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

chatmap-api/main.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ async def get_video_player(
326326
if media_url.endswith("mp4"):
327327
html_response += f"""
328328
<video width="490" height="350" style="background-color: #111; border-radius: 4px" controls>
329-
<source src="/v{API_VERSION}/media/{media_url}" type="video/mp4">
329+
<source src="{API_URL}/v{API_VERSION}/media?filename={media_url}" type="video/mp4">
330330
Your browser does not support the video tag.
331331
</video>
332332
"""
@@ -339,7 +339,7 @@ async def get_video_player(
339339
file_type = media_url[-4:] if media_url.endswith("opus") else media_url[-3:]
340340
html_response += f"""
341341
<audio width="490" height="68" style="background-color: #111; border-radius: 4px" controls>
342-
<source src="/v{API_VERSION}/media/{media_url}" type="audio/{file_type}">
342+
<source src="{API_URL}/v{API_VERSION}/media?filename={media_url}" type="audio/{file_type}">
343343
Your browser does not support the audio tag.
344344
</audio>
345345
"""
@@ -353,7 +353,7 @@ async def get_video_player(
353353
# Retrieve HTML for embedded media (image/video/audio)
354354
def html_for_embedded_media(file):
355355
if file:
356-
file_url = file.replace("http:", "").replace("https:", "").replace("media", "media_player")
356+
file_url = f"{API_URL}/v{API_VERSION}/media_player/{file}"
357357
if file.endswith("jpg") or file.endswith("jpeg"):
358358
return file
359359
elif file.endswith("mp4"):
@@ -642,7 +642,6 @@ async def get_media(
642642
detail="Media not found",
643643
)
644644

645-
646645
# Media File Endpoint
647646
@api_router.get("/media")
648647
async def media(filename: str) -> Dict[str, str]:

0 commit comments

Comments
 (0)