bool CLastFmManager::CanScrobble(const CFileItem &fileitem) { return ( (!fileitem.IsInternetStream() && g_guiSettings.GetBool("scrobbler.lastfmsubmit")) || (fileitem.IsLastFM() && g_guiSettings.GetBool("scrobbler.lastfmsubmitradio")) ); }
bool CLastFmManager::CanScrobble(const CFileItem &fileitem) { return ( (!fileitem.IsInternetStream() && g_guiSettings.GetBool("lastfm.enable")) || (fileitem.IsLastFM() && g_guiSettings.GetBool("lastfm.recordtoprofile")) ); }
bool CGUIWindowMusicBase::OnPlayMedia(int iItem) { CFileItem* pItem = m_vecItems->Get(iItem); if (pItem->m_strPath == "add" && pItem->GetLabel() == g_localizeStrings.Get(1026)) // 'add source button' in empty root { if (CGUIDialogMediaSource::ShowAndAddMediaSource("music")) { Update(""); return true; } return false; } // party mode if (g_partyModeManager.IsEnabled() && !pItem->IsLastFM()) { CPlayList playlistTemp; CPlayListItem playlistItem; CUtil::ConvertFileItemToPlayListItem(m_vecItems->Get(iItem), playlistItem); playlistTemp.Add(playlistItem); g_partyModeManager.AddUserSongs(playlistTemp, true); return true; } else if (!pItem->IsPlayList() && !pItem->IsInternetStream()) { // single music file - if we get here then we have autoplaynextitem turned off, but we // still want to use the playlist player in order to handle more queued items following etc. g_playlistPlayer.Reset(); g_playlistPlayer.ClearPlaylist(PLAYLIST_MUSIC); g_playlistPlayer.Add(PLAYLIST_MUSIC, pItem); g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_MUSIC); g_playlistPlayer.Play(); return true; } return CGUIMediaWindow::OnPlayMedia(iItem); }
bool CPlayListFactory::IsPlaylist(const CFileItem& item, bool bAllowQuery) { CStdString extension = CUtil::GetExtension(item.m_strPath); extension.ToLower(); if (extension == ".m3u") return true; if (extension == ".m3u8") return true; if (extension == ".b4s") return true; if (extension == ".pls") return true; if (extension == ".strm") return true; if (extension == ".wpl") return true; if (extension == ".asx") return true; if (extension == ".ram") return true; if (item.IsLastFM()) return false; if (extension == ".url") return true; if (extension == ".pxml") return true; if (item.IsShoutCast()) return false; if( item.IsInternetStream() ) { CStdString strContentType = item.GetContentType(bAllowQuery); strContentType.MakeLower(); if (strContentType == "video/x-ms-asf" || strContentType == "video/x-ms-asx" || strContentType == "video/x-ms-wfs" || strContentType == "video/x-ms-wvx" || strContentType == "video/x-ms-wax" || strContentType == "audio/x-pn-realaudio" || strContentType == "audio/x-scpls" || strContentType == "playlist" || strContentType == "audio/x-mpegurl" || strContentType == "application/vnd.ms-wpl") return true; } return false; }
void CLastFmManager::OnSongChange(CFileItem& newSong) { if (IsRadioEnabled()) { if (!newSong.IsLastFM()) { StopRadio(true); } else { unsigned int start = XbmcThreads::SystemClockMillis(); ReapSongs(); MovePlaying(); Update(); SendUpdateMessage(); CLog::Log(LOGDEBUG, "%s: Done (time: %i ms)", __FUNCTION__, (int)(XbmcThreads::SystemClockMillis() - start)); } } m_CurrentSong.IsLoved = false; m_CurrentSong.IsBanned = false; m_CurrentSong.CurrentSong = &newSong; }
void PAPlayer::UpdateCrossFadingTime(const CFileItem& file) { if ((m_crossFading = g_guiSettings.GetInt("mymusic.crossfade"))) { if ( m_crossFading && ( file.IsCDDA() || file.IsLastFM() || ( file.HasMusicInfoTag() && !g_guiSettings.GetBool("mymusic.crossfadealbumtracks") && (m_currentFile->GetMusicInfoTag()->GetAlbum() != "") && (m_currentFile->GetMusicInfoTag()->GetAlbum() == file.GetMusicInfoTag()->GetAlbum()) && (m_currentFile->GetMusicInfoTag()->GetDiscNumber() == file.GetMusicInfoTag()->GetDiscNumber()) && (m_currentFile->GetMusicInfoTag()->GetTrackNumber() == file.GetMusicInfoTag()->GetTrackNumber() - 1) ) ) ) { m_crossFading = 0; } } }
void PAPlayer::UpdateCrossFadingTime(const CFileItem& file) { if ((m_crossFading = g_guiSettings.GetInt("musicplayer.crossfade"))) { if ( m_crossFading && ( file.IsCDDA() || file.IsLastFM() || ( file.HasMusicInfoTag() && !g_guiSettings.GetBool("musicplayer.crossfadealbumtracks") && (m_currentFile->GetMusicInfoTag()->GetAlbum() != "") && (m_currentFile->GetMusicInfoTag()->GetAlbum() == file.GetMusicInfoTag()->GetAlbum()) && (m_currentFile->GetMusicInfoTag()->GetDiscNumber() == file.GetMusicInfoTag()->GetDiscNumber()) && (m_currentFile->GetMusicInfoTag()->GetTrackNumber() == file.GetMusicInfoTag()->GetTrackNumber() - 1) ) || g_guiSettings.GetString("audiooutput.audiodevice").find("wasapi:") != CStdString::npos ) ) { m_crossFading = 0; } } }
bool PAPlayer::OpenFile(const CFileItem& file, const CPlayerOptions &options) { if (m_currentlyCrossFading) CloseFileInternal(false); //user seems to be in a hurry m_crossFading = g_guiSettings.GetInt("musicplayer.crossfade"); //WASAPI doesn't support multiple streams, no crossfading for cdda, cd-reading goes mad and no crossfading for last.fm doesn't like two connections if (file.IsCDDA() || file.IsLastFM() || g_guiSettings.GetString("audiooutput.audiodevice").find("wasapi:") != CStdString::npos) m_crossFading = 0; if (m_crossFading && IsPlaying()) { //do a short crossfade on trackskip //set to max 2 seconds for these prev/next transitions if (m_crossFading > 2) m_crossFading = 2; //queue for crossfading bool result = QueueNextFile(file, false); if (result) { //crossfading value may be update by QueueNextFile when nr of channels changed if (!m_crossFading) // swap to next track m_decoder[m_currentDecoder].SetStatus(STATUS_ENDED); else //force to fade to next track immediately m_forceFadeToNext = true; } return result; } // normal opening of file, nothing playing or crossfading not enabled // however no need to return to gui audio device CloseFileInternal(false); // always open the file using the current decoder m_currentDecoder = 0; if (!m_decoder[m_currentDecoder].Create(file, (__int64)(options.starttime * 1000), m_crossFading)) return false; m_iSpeed = 1; m_bPaused = false; m_bStopPlaying = false; m_bytesSentOut = 0; CLog::Log(LOGINFO, "PAPlayer: Playing %s", file.m_strPath.c_str()); m_timeOffset = (__int64)(options.starttime * 1000); unsigned int channel, sampleRate, bitsPerSample; m_decoder[m_currentDecoder].GetDataFormat(&channel, &sampleRate, &bitsPerSample); if (!CreateStream(m_currentStream, channel, sampleRate, bitsPerSample)) { m_decoder[m_currentDecoder].Destroy(); CLog::Log(LOGERROR, "PAPlayer::Unable to create audio stream"); } *m_currentFile = file; if (ThreadHandle() == NULL) Create(); m_startEvent.Set(); m_bIsPlaying = true; m_cachingNextFile = false; m_currentlyCrossFading = false; m_forceFadeToNext = false; m_bQueueFailed = false; m_decoder[m_currentDecoder].Start(); // start playback return true; }
void CGUIWindowMusicNav::GetContextButtons(int itemNumber, CContextButtons &buttons) { CGUIWindowMusicBase::GetContextButtons(itemNumber, buttons); CGUIDialogMusicScan *musicScan = (CGUIDialogMusicScan *)m_gWindowManager.GetWindow(WINDOW_DIALOG_MUSIC_SCAN); CFileItem *item = (itemNumber >= 0 && itemNumber < m_vecItems->Size()) ? m_vecItems->Get(itemNumber) : NULL; if (item && (item->GetExtraInfo().Find("lastfm") < 0)) { // are we in the playlists location? bool inPlaylists = m_vecItems->m_strPath.Equals(CUtil::MusicPlaylistsLocation()) || m_vecItems->m_strPath.Equals("special://musicplaylists/"); CMusicDatabaseDirectory dir; SScraperInfo info; m_musicdatabase.GetScraperForPath(item->m_strPath,info); // enable music info button on an album or on a song. if (item->IsAudio() && !item->IsPlayList() && !item->IsSmartPlayList() && !item->IsLastFM() && !item->IsShoutCast()) { buttons.Add(CONTEXT_BUTTON_SONG_INFO, 658); } else if (item->IsVideoDb()) { if (!item->m_bIsFolder) // music video buttons.Add(CONTEXT_BUTTON_INFO, 20393); if (item->m_strPath.Left(14).Equals("videodb://3/4/") && item->m_strPath.size() > 14 && item->m_bIsFolder) { long idArtist = m_musicdatabase.GetArtistByName(m_vecItems->Get(itemNumber)->GetLabel()); if (idArtist > - 1) buttons.Add(CONTEXT_BUTTON_INFO,21891); } } else if (!inPlaylists && (dir.HasAlbumInfo(item->m_strPath)|| dir.IsArtistDir(item->m_strPath) ) && !dir.IsAllItem(item->m_strPath) && !item->IsParentFolder() && !item->IsLastFM() && !item->IsShoutCast() && !item->m_strPath.Left(14).Equals("musicsearch://")) { if (dir.IsArtistDir(item->m_strPath)) buttons.Add(CONTEXT_BUTTON_INFO, 21891); else buttons.Add(CONTEXT_BUTTON_INFO, 13351); } // enable query all albums button only in album view if (dir.HasAlbumInfo(item->m_strPath) && !dir.IsAllItem(item->m_strPath) && item->m_bIsFolder && !item->IsVideoDb() && !item->IsParentFolder() && !item->IsLastFM() && !item->IsShoutCast() && !item->m_strPath.Left(14).Equals("musicsearch://")) { buttons.Add(CONTEXT_BUTTON_INFO_ALL, 20059); } // enable query all artist button only in album view if (dir.IsArtistDir(item->m_strPath) && !dir.IsAllItem(item->m_strPath) && item->m_bIsFolder && !item->IsVideoDb() && !info.strContent.IsEmpty()) { buttons.Add(CONTEXT_BUTTON_INFO_ALL, 21884); } // turn off set artist image if not at artist listing. if (dir.IsArtistDir(item->m_strPath) && !dir.IsAllItem(item->m_strPath) || (item->m_strPath.Left(14).Equals("videodb://3/4/") && item->m_strPath.size() > 14 && item->m_bIsFolder)) { buttons.Add(CONTEXT_BUTTON_SET_ARTIST_THUMB, 13359); } if (m_vecItems->m_strPath.Equals("plugin://music/")) buttons.Add(CONTEXT_BUTTON_SET_PLUGIN_THUMB, 1044); //Set default or clear default NODE_TYPE nodetype = dir.GetDirectoryType(item->m_strPath); if (!item->IsParentFolder() && !inPlaylists && (nodetype == NODE_TYPE_ROOT || nodetype == NODE_TYPE_OVERVIEW || nodetype == NODE_TYPE_TOP100)) { if (!item->m_strPath.Equals(g_settings.m_defaultMusicLibSource)) buttons.Add(CONTEXT_BUTTON_SET_DEFAULT, 13335); // set default if (strcmp(g_settings.m_defaultMusicLibSource, "")) buttons.Add(CONTEXT_BUTTON_CLEAR_DEFAULT, 13403); // clear default } NODE_TYPE childtype = dir.GetDirectoryChildType(item->m_strPath); if (childtype == NODE_TYPE_ALBUM || childtype == NODE_TYPE_ARTIST || nodetype == NODE_TYPE_GENRE || nodetype == NODE_TYPE_ALBUM) { // we allow the user to set content for // 1. general artist and album nodes // 2. specific per genre // 3. specific per artist // 4. specific per album buttons.Add(CONTEXT_BUTTON_SET_CONTENT,20195); } if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetArtist().size() > 0) { CVideoDatabase database; database.Open(); if (database.GetMusicVideoArtistByName(item->GetMusicInfoTag()->GetArtist()) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ARTIST, 20400); } if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetArtist().size() > 0 && item->GetMusicInfoTag()->GetAlbum().size() > 0 && item->GetMusicInfoTag()->GetTitle().size() > 0) { CVideoDatabase database; database.Open(); if (database.GetMusicVideoByArtistAndAlbumAndTitle(item->GetMusicInfoTag()->GetArtist(),item->GetMusicInfoTag()->GetAlbum(),item->GetMusicInfoTag()->GetTitle()) > -1) buttons.Add(CONTEXT_BUTTON_PLAY_OTHER, 20401); } if (item->HasVideoInfoTag() && !item->m_bIsFolder) { if (item->GetVideoInfoTag()->m_bWatched) buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched else buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched if (g_settings.m_vecProfiles[g_settings.m_iLastLoadedProfileIndex].canWriteDatabases() || g_passwordManager.bMasterUser) { buttons.Add(CONTEXT_BUTTON_RENAME, 16105); buttons.Add(CONTEXT_BUTTON_DELETE, 646); } } } // noncontextual buttons if (musicScan && musicScan->IsScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); // Stop Scanning else if (musicScan) buttons.Add(CONTEXT_BUTTON_UPDATE_LIBRARY, 653); CGUIWindowMusicBase::GetNonContextButtons(buttons); }