MediaPlayer::SupportsType MediaPlayer::supportsType(ContentType contentType) { String type = contentType.type(); String codecs = contentType.parameter("codecs"); MediaPlayerFactory* engine = chooseBestEngineForTypeAndCodecs(type, codecs); if (!engine) return IsNotSupported; return engine->supportsTypeAndCodecs(type, codecs); }
void MediaPlayer::load(const String& url, const ContentType& contentType) { String type = contentType.type(); String codecs = contentType.parameter("codecs"); // if we don't know the MIME type, see if the extension can help if (type.isEmpty() || type == "application/octet-stream" || type == "text/plain") { int pos = url.reverseFind('.'); if (pos >= 0) { String extension = url.substring(pos + 1); String mediaType = MIMETypeRegistry::getMediaMIMETypeForExtension(extension); if (!mediaType.isEmpty()) type = mediaType; } } MediaPlayerFactory* engine = 0; if (!type.isEmpty()) engine = chooseBestEngineForTypeAndCodecs(type, codecs); // if we didn't find an engine that claims the MIME type, just use the first engine if (!engine && !installedMediaEngines().isEmpty()) engine = installedMediaEngines()[0]; // don't delete and recreate the player unless it comes from a different engine if (engine && m_currentMediaEngine != engine) { m_currentMediaEngine = engine; m_private.clear(); m_private.set(engine->constructor(this)); #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) m_private->setMediaPlayerProxy(m_playerProxy); #endif m_private->setAutobuffer(autobuffer()); m_private->setPreservesPitch(preservesPitch()); } if (m_private) m_private->load(url); else m_private.set(createNullMediaPlayer(this)); }