diff options
Diffstat (limited to 'avmedia')
-rw-r--r-- | avmedia/source/framework/mediaitem.cxx | 9 | ||||
-rw-r--r-- | avmedia/source/inc/mediamisc.hxx | 5 | ||||
-rw-r--r-- | avmedia/source/viewer/mediawindow_impl.cxx | 7 |
3 files changed, 11 insertions, 10 deletions
diff --git a/avmedia/source/framework/mediaitem.cxx b/avmedia/source/framework/mediaitem.cxx index 77b28918f545..f177c8bea687 100644 --- a/avmedia/source/framework/mediaitem.cxx +++ b/avmedia/source/framework/mediaitem.cxx @@ -36,6 +36,7 @@ #include <ucbhelper/content.hxx> +#include <comphelper/mediamimetype.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/storagehelper.hxx> #include <mediamisc.hxx> @@ -237,6 +238,7 @@ bool MediaItem::setURL(const OUString& rURL, const OUString& rTempURL, const OUS m_pImpl->m_URL = rURL; m_pImpl->m_TempFileURL = rTempURL; m_pImpl->m_Referer = rReferer; + setMimeType(::comphelper::GuessMediaMimeType(GetFilename(rURL))); } return bChanged; } @@ -447,10 +449,9 @@ CreateStream(uno::Reference<embed::XStorage> const& xStorage, uno::Reference< beans::XPropertySet > const xStreamProps(xStream, uno::UNO_QUERY); if (xStreamProps.is()) { // this is NOT supported in FileSystemStorage - xStreamProps->setPropertyValue("MediaType", uno::Any(OUString( - //FIXME how to detect real media type? - //but currently xmloff has this one hardcoded anyway... - "application/vnd.sun.star.media"))); + OUString const guessed(::comphelper::GuessMediaMimeType(filename)); + xStreamProps->setPropertyValue("MediaType", + uno::Any(guessed.isEmpty() ? AVMEDIA_MIMETYPE_COMMON : guessed)); xStreamProps->setPropertyValue( // turn off compression "Compressed", uno::Any(false)); } diff --git a/avmedia/source/inc/mediamisc.hxx b/avmedia/source/inc/mediamisc.hxx index 061a7177f05a..f45f5b50da0b 100644 --- a/avmedia/source/inc/mediamisc.hxx +++ b/avmedia/source/inc/mediamisc.hxx @@ -19,6 +19,8 @@ #pragma once +#include <comphelper/mediamimetype.hxx> + #include <unotools/resmgr.hxx> #ifdef _WIN32 @@ -31,9 +33,6 @@ #endif #endif -// Mime types -inline constexpr OUStringLiteral AVMEDIA_MIMETYPE_COMMON = u"application/vnd.sun.star.media"; - inline OUString AvmResId(TranslateId aId) { return Translate::get(aId, Translate::Create("avmedia")); diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx index b74033e33749..82ca1b92821c 100644 --- a/avmedia/source/viewer/mediawindow_impl.cxx +++ b/avmedia/source/viewer/mediawindow_impl.cxx @@ -168,7 +168,7 @@ void MediaWindowImpl::dispose() Control::dispose(); } -uno::Reference<media::XPlayer> MediaWindowImpl::createPlayer(const OUString& rURL, const OUString& rReferer, const OUString* pMimeType) +uno::Reference<media::XPlayer> MediaWindowImpl::createPlayer(const OUString& rURL, const OUString& rReferer, const OUString*) { uno::Reference<media::XPlayer> xPlayer; @@ -180,7 +180,8 @@ uno::Reference<media::XPlayer> MediaWindowImpl::createPlayer(const OUString& rUR return xPlayer; } - if (!pMimeType || *pMimeType == AVMEDIA_MIMETYPE_COMMON) + // currently there isn't anything else, throw any mime type to the media players + //if (!pMimeType || *pMimeType == AVMEDIA_MIMETYPE_COMMON) { uno::Reference<uno::XComponentContext> xContext(::comphelper::getProcessComponentContext()); if (Application::GetToolkitName() == "gtk4") @@ -397,7 +398,7 @@ void MediaWindowImpl::stopPlayingInternal(bool bStop) void MediaWindowImpl::onURLChanged() { - if (m_sMimeType == AVMEDIA_MIMETYPE_COMMON) + //if (m_sMimeType == AVMEDIA_MIMETYPE_COMMON) { mpChildWindow.disposeAndClear(); mpChildWindow.reset(VclPtr<MediaChildWindow>::Create(this)); |