/** Begin play a movie in the playlist. * Private method. */ void PlaylistFrame::BeginPlayFile() { if (m_itemPlaying < m_playlist.GetSize()) { const Channel *channel = m_appInterface->GetCurrentChannel(); //Get channel bitrate Mode mode; ModeList modeList = channel->GetModeList(); modeList.FindMode(IRM_MODE_CHANNEL_BITRATE, mode); long bitrate; mode.GetParameter().ToLong(&bitrate); PlaylistItem item; std::list<PlaylistItem>::const_iterator it; it = m_playlist.Begin(); for(int i = 0;i<m_itemPlaying;i++) it++; item = *it; bool ret = m_appInterface->MovieBeginTransmission(channel->GetName(), item.GetPath(), bitrate); SetFieldsStates(ret); m_lstBoxPlaylist->SetSelection(m_itemPlaying); SetStatusText(wxString::Format(_("Playing file: %s"), item.GetFilename().c_str())); if (!ret) { wxString msg = wxString::Format(_("Error while attempt play %s"), item.GetFilename().c_str()); wxMessageBox(msg, wxMessageBoxCaptionStr, wxOK|wxICON_ERROR, this); } } else { if (m_chkBoxRepeat->IsChecked()) { m_itemPlaying = 0; BeginPlayFile(); } else { wxString msg = _("Finished send transmission of Playlist"); wxMessageBox(msg, _("Information"), wxICON_INFORMATION|wxOK, this); m_appInterface->MovieCancelTransmission(m_mediaId); SetFieldsStates(false); SetStatusText(wxEmptyString); } } }
/** Save playlist to file. * Private method. Return true if file was saved or false if occurs a error. */ bool PlaylistFrame::SavePlaylist() { //If don�t have playlist, don�t create file if (m_playlist.GetSize() == 0) return false; wxString wildcard = _("Playlist|*.ivl"); wxFileDialog fileDlg(this, wxFileSelectorPromptStr, wxEmptyString, wxEmptyString, wildcard, wxFD_SAVE); if (fileDlg.ShowModal() == wxID_OK) { wxString filePath = fileDlg.GetPath(); if (wxFile::Access(filePath, wxFile::write)) { MessageDialog msgDlg(this, _("Confirm"), _("Overwite file?")); if ( msgDlg.ShowModal() == ID_MESSAGEDIALOG_BTN_NO) return false; } #ifdef __WXGTK__ filePath += wxT(".ivl"); ofstream playlistFile(WX_TO_FILE_CSTR(filePath)); #else ofstream playlistFile(WX_TO_FILE_CSTR(filePath)); #endif PlaylistItem item; std::list<PlaylistItem>::iterator it; for(it = m_playlist.Begin(); it != m_playlist.End(); it++) { item = *it; playlistFile << WX_TO_FILE_CSTR(item.GetPath()) << "\n"; } playlistFile.close(); wxMessageBox(_("Playlist saved successfully."), _("Information"), wxOK, this); } return true; }