diff options
author | CastagnaIT <gottardo.stefano.83@gmail.com> | 2023-01-03 17:25:55 +0100 |
---|---|---|
committer | CastagnaIT <gottardo.stefano.83@gmail.com> | 2023-01-14 09:19:02 +0100 |
commit | 028edee92254739518345ca3f04dbb4d8da30774 (patch) | |
tree | d42e8eeb3ec784693ff672657a7c5a0ba69c0fbd | |
parent | 6048b035a3d7dd21f1e4870a783ad27f8b450e1f (diff) |
[PlayListPlayer] Fix hint on playlist file with multiple paths
-rw-r--r-- | xbmc/PlayListPlayer.cpp | 30 | ||||
-rw-r--r-- | xbmc/interfaces/builtins/PlayerBuiltins.cpp | 7 | ||||
-rw-r--r-- | xbmc/music/windows/GUIWindowMusicBase.cpp | 2 | ||||
-rw-r--r-- | xbmc/video/windows/GUIWindowVideoBase.cpp | 2 |
4 files changed, 29 insertions, 12 deletions
diff --git a/xbmc/PlayListPlayer.cpp b/xbmc/PlayListPlayer.cpp index b73cd665e0..b86e1cfbdf 100644 --- a/xbmc/PlayListPlayer.cpp +++ b/xbmc/PlayListPlayer.cpp @@ -263,21 +263,31 @@ bool CPlayListPlayer::Play(const CFileItemPtr& pItem, const std::string& player) Id playlistId; bool isVideo{pItem->IsVideo()}; bool isAudio{pItem->IsAudio()}; - if (isVideo && isAudio && pItem->HasProperty("playlist_type_hint")) + + if (isAudio && !isVideo) + playlistId = TYPE_MUSIC; + else if (isVideo && !isAudio) + playlistId = TYPE_VIDEO; + else if (pItem->HasProperty("playlist_type_hint")) { - // If an extension is set in both audio / video lists (e.g. playlist .strm), - // is not possible detect the type of playlist then we rely on the hint + // There are two main cases that can fall here: + // - If an extension is set on both audio / video extension lists example .strm + // see GetFileExtensionProvider() -> GetVideoExtensions() / GetAudioExtensions() + // When you play the .strm containing single path, cause that + // IsVideo() and IsAudio() methods both return true + // + // - When you play a playlist (e.g. .m3u / .strm) containing multiple paths, + // and the path played is generic (e.g.without extension) and have no properties + // to detect the media type, IsVideo() / IsAudio() both return false + // + // for these cases the type is unknown so we rely on the hint playlistId = pItem->GetProperty("playlist_type_hint").asInteger32(TYPE_NONE); } - else if (isAudio) - playlistId = TYPE_MUSIC; - else if (isVideo) - playlistId = TYPE_VIDEO; else { - CLog::Log( - LOGWARNING, - "Playlist Player: ListItem type must be audio or video, use ListItem::setInfo to specify!"); + CLog::LogF(LOGWARNING, "ListItem type must be audio or video type. The type can be specified " + "by using ListItem::getVideoInfoTag or ListItem::getMusicInfoTag, in " + "the case of playlist entries by adding #KODIPROP mimetype value."); return false; } diff --git a/xbmc/interfaces/builtins/PlayerBuiltins.cpp b/xbmc/interfaces/builtins/PlayerBuiltins.cpp index 8620d988b2..ca69d69ea1 100644 --- a/xbmc/interfaces/builtins/PlayerBuiltins.cpp +++ b/xbmc/interfaces/builtins/PlayerBuiltins.cpp @@ -597,9 +597,16 @@ int PlayOrQueueMedia(const std::vector<std::string>& params, bool forcePlay) } if ((item.IsAudio() || item.IsVideo()) && !item.IsSmartPlayList()) + { + if (!item.HasProperty("playlist_type_hint")) + item.SetProperty("playlist_type_hint", PLAYLIST::TYPE_MUSIC); + CServiceBroker::GetPlaylistPlayer().Play(std::make_shared<CFileItem>(item), ""); + } else + { g_application.PlayMedia(item, "", PLAYLIST::TYPE_NONE); + } } return 0; diff --git a/xbmc/music/windows/GUIWindowMusicBase.cpp b/xbmc/music/windows/GUIWindowMusicBase.cpp index 49fa03a8c9..df45141c9b 100644 --- a/xbmc/music/windows/GUIWindowMusicBase.cpp +++ b/xbmc/music/windows/GUIWindowMusicBase.cpp @@ -741,7 +741,7 @@ bool CGUIWindowMusicBase::OnPlayMedia(int iItem, const std::string &player) OnQueueItem(iItem); return true; } - pItem->SetProperty("playlist_type_hint", PLAYLIST::TYPE_MUSIC); + pItem->SetProperty("playlist_type_hint", m_guiState->GetPlaylist()); CServiceBroker::GetPlaylistPlayer().Play(pItem, player); return true; } diff --git a/xbmc/video/windows/GUIWindowVideoBase.cpp b/xbmc/video/windows/GUIWindowVideoBase.cpp index bc3e7c58ef..161dec7f12 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.cpp +++ b/xbmc/video/windows/GUIWindowVideoBase.cpp @@ -1005,7 +1005,7 @@ bool CGUIWindowVideoBase::OnPlayMedia(int iItem, const std::string &player) } CLog::Log(LOGDEBUG, "{} {}", __FUNCTION__, CURL::GetRedacted(item.GetPath())); - item.SetProperty("playlist_type_hint", PLAYLIST::TYPE_VIDEO); + item.SetProperty("playlist_type_hint", m_guiState->GetPlaylist()); PlayMovie(&item, player); |