本文整理汇总了C++中PlaylistItem类的典型用法代码示例。如果您正苦于以下问题:C++ PlaylistItem类的具体用法?C++ PlaylistItem怎么用?C++ PlaylistItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PlaylistItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addTrack
/** Add a track and set it as current item */
void Playlist::addCurrentTrack( Track* track )
{
//Add if it comes from outsite only
bool fromOutsite=true;
PlaylistItem* currItem = (PlaylistItem*)currentItem();
if ( currItem )
if ( track->url() == currItem->track()->url() )
fromOutsite=false;
if ( fromOutsite )
addTrack(track,NULL);
else
newPlaylistItem = currItem;
if (!m_isPlaying){
//is not playing, direct into player and roll others
setCurrentPlaylistItem( newPlaylistItem );
} else {
//is playing, wait and add as next
setNextPlaylistItem( newPlaylistItem );
}
handleChanges();
}
示例2: if
void
SourceTreeView::addToLocal()
{
QModelIndex idx = m_contextMenuIndex;
if ( !idx.isValid() )
return;
SourcesModel::RowType type = ( SourcesModel::RowType )model()->data( m_contextMenuIndex, SourcesModel::SourceTreeItemTypeRole ).toInt();
if( type == SourcesModel::AutomaticPlaylist || type == SourcesModel::Station )
{
DynamicPlaylistItem* item = itemFromIndex< DynamicPlaylistItem >( m_contextMenuIndex );
dynplaylist_ptr playlist = item->dynPlaylist();
// copy to a link and then generate a new playlist from that
// this way we cheaply regenerate the needed controls
QString link = GlobalActionManager::instance()->copyPlaylistToClipboard( playlist );
GlobalActionManager::instance()->parseTomahawkLink( link );
}
else if ( type == SourcesModel::StaticPlaylist )
{
PlaylistItem* item = itemFromIndex< PlaylistItem >( m_contextMenuIndex );
playlist_ptr playlist = item->playlist();
// just create the new playlist with the same values
QList< query_ptr > queries;
foreach( const plentry_ptr& e, playlist->entries() )
queries << e->query();
playlist_ptr newpl = Playlist::create( SourceList::instance()->getLocal(), uuid(), playlist->title(), playlist->info(), playlist->creator(), playlist->shared(), queries );
}
示例3: local
bool PlaylistSaver::saveM3U(const KURL &file, int opt)
{
// kdDebug(66666) << k_funcinfo << "file='" << file.path() << "', opt=" << opt << endl;
bool isExt=(opt==EXTM3U); // easier ;)
QString local(napp->tempSaveName(file.path()));
QFile saver(local);
saver.open(IO_ReadWrite | IO_Truncate);
QTextStream t(&saver);
reset();
PlaylistItem i;
QStringList props;
// this is more code but otoh faster than checking for isExt inside the loop
if(isExt)
{
t << "#EXTM3U" << '\n';
while ((i=writeItem()))
{
int length = static_cast<int>(((i.property("length")).toInt())/1000);
if(length==0) length=-1; // special value in an EXTM3U file, means "unknown"
KURL u(i.property("url"));
QString title;
// if a playlistitem is without a tag or ONLY title is set
if((i.property("author").isEmpty() && i.property("title").isEmpty())
|| (i.property("author").isEmpty() && !i.property("title").isEmpty()) )
title = u.filename().left(u.filename().length()-4);
else
title = i.property("author") + " - " + i.property("title");
// kdDebug(66666) << "#EXTINF:"<< QString::number(length) << "," << title << endl;
t << "#EXTINF:"<< QString::number(length) << "," << title << '\n';
if (u.isLocalFile())
t << u.path() << '\n';
else
t << u.url() << '\n';
}
}
else
{
while ((i=writeItem()))
{
KURL u(i.property("url"));
if (u.isLocalFile())
t << u.path() << '\n';
else
t << u.url() << '\n';
}
}
saver.close();
KIO::NetAccess::upload(local, file, 0L);
saver.remove();
return true;
}
示例4: PLItemsCommand
CopyPLItemsCommand::CopyPLItemsCommand(Playlist* playlist,
const int32* indices, int32 count, int32 toIndex)
:
PLItemsCommand(),
fPlaylist(playlist),
fItems(count > 0 ? new (nothrow) PlaylistItem*[count] : NULL),
fToIndex(toIndex),
fCount(count),
fItemsCopied(false)
{
if (!indices || !fPlaylist || !fItems) {
// indicate a bad object state
delete[] fItems;
fItems = NULL;
return;
}
memset(fItems, 0, sizeof(PlaylistItem*) * fCount);
// init original entries and
for (int32 i = 0; i < fCount; i++) {
PlaylistItem* item = fPlaylist->ItemAt(indices[i]);
if (item != NULL)
fItems[i] = item->Clone();
if (fItems[i] == NULL) {
// indicate a bad object state
_CleanUp(fItems, fCount, true);
return;
}
}
}
示例5: setUpdateSignaled
bool PlaylistsModel::load()
{
setUpdateSignaled(false);
if (!m_provider)
return false;
clear();
const SONOS::PlayerPtr player = m_provider->getPlayer();
if (!player)
return false;
QString port;
port.setNum(player->GetPort());
QString url = "http://";
url.append(player->GetHost().c_str()).append(":").append(port);
SONOS::ContentDirectory cd(player->GetHost(), player->GetPort());
SONOS::ContentList cl(cd, m_root.isEmpty() ? SONOS::ContentSearch(SONOS::SearchSonosPlaylist,"").Root() : m_root.toUtf8().constData());
for (SONOS::ContentList::iterator it = cl.begin(); it != cl.end(); ++it)
{
PlaylistItem* item = new PlaylistItem(*it, url);
if (item->isValid())
addItem(item);
else
delete item;
}
if (cl.failure())
return m_loaded = false;
m_updateID = cl.GetUpdateID(); // sync new baseline
return m_loaded = true;
}
示例6: file
void PLSimport::readFile()
{
QFile file(filename);
if (!file.open(QFile::ReadOnly)) {
return;
}
QTextStream is(&file);
PlaylistItem* p;
// QString* duration;
// QString* title;
QString* uri;
QRegExp rxlen("=");
QRegExp rxlen2("(\\d+)");
int pos=-1;
is.readLine();
int i = rxlen2.indexIn(is.readLine());
if(i>-1)
i = rxlen2.cap(1).toInt();
is.readLine();
for(int j = 0 ;j<i;j++)
{
p= new PlaylistItem;
uri = new QString;
*uri = is.readLine();
pos = rxlen.indexIn(*uri);
if (pos > -1)
{
uri->remove(0, pos+1);
}
is.readLine();
is.readLine();
is.readLine();
p->setURI(*uri);
result->append(p);
}
}
示例7: CountItems
void
Playlist::MakeEmpty(bool deleteItems)
{
int32 count = CountItems();
for (int32 i = count - 1; i >= 0; i--) {
PlaylistItem* item = RemoveItem(i, false);
_NotifyItemRemoved(i);
if (deleteItems)
item->ReleaseReference();
}
SetCurrentItemIndex(-1);
}
示例8: PlaylistItem
void Playlist::addTrack( Track* track, PlaylistItem* after )
{
if (!track || !track->isValid())
return;
//qDebug() << __PRETTY_FUNCTION__ <<":"<<objectName()<<" url="<<track->url();
PlaylistItem* item = new PlaylistItem( this, after );
item->setTexts( track );
newPlaylistItem = item;
RatingWidget* rating= new RatingWidget();
rating->setRating( track->rate() * 0.1 );
QObject::connect(rating,SIGNAL(RatingChanged(float)),SLOT(onRatingChanged(float)));
setItemWidget(item, PlaylistItem::Column_Rate, rating);
}
示例9: UpdatePlaylist
/** Updates the playlist listbox.
*
*/
void PlaylistFrame::UpdatePlaylist()
{
//Clear playlist
m_lstBoxPlaylist->Clear();
m_lstBoxPlaylist->SetForegroundColour(wxColour(0,255,0));
PlaylistItem item;
std::list<PlaylistItem>::const_iterator it;
for(it = m_playlist.Begin(); it != m_playlist.End(); it++)
{
item = *it;
m_lstBoxPlaylist->Append(item.GetFilename());
}
}
示例10: BeginPlayFile
/** 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);
}
}
}
示例11: doc
bool PlaylistSaver::saveXML(const KURL &file, int )
{
QString localFile;
if (file.isLocalFile())
localFile = QFile::encodeName(file.path());
else
localFile = napp->tempSaveName(file.path());
// QDom is a pain :)
QDomDocument doc("playlist");
doc.setContent(QString("<!DOCTYPE XMLPlaylist><playlist version=\"1.0\" client=\"noatun\"/>"));
QDomElement docElem=doc.documentElement();
reset();
PlaylistItem i;
QStringList props;
while ((i=writeItem()))
{
// write all properties
props=i.properties();
QDomElement elem=doc.createElement("item");
for (QStringList::Iterator pi(props.begin()); pi!=props.end(); ++pi)
{
QString val=i.property(*pi);
elem.setAttribute(*pi, val);
if ((*pi)=="url")
{
KURL u(val);
if (u.isLocalFile())
{
elem.setAttribute("local", u.path());
}
}
}
docElem.appendChild(elem);
props.clear();
}
Noatun::KSaver saver(localFile);
if (!saver.open())
return false;
saver.textStream().setEncoding(QTextStream::UnicodeUTF8);
saver.textStream() << doc.toString();
saver.close();
return true;
}
示例12: QueueItem
void
QueueManager::insertItems()
{
QPtrList<PlaylistItem> list = Playlist::instance()->m_nextTracks;
QListViewItem *last = 0;
for( PlaylistItem *item = list.first(); item; item = list.next() )
{
QString title = i18n("%1 - %2").arg( item->artist(), item->title() );
last = new QueueItem( m_listview, last, title );
m_map[ last ] = item;
}
updateButtons();
}
示例13: addItems
void Playlist::addItems(const PlaylistItem &item)
{
QVariantMap params;
params.insert("item", item.toMap());
params.insert("playlistid", playlistId());
KodiConnection::sendCommand("Playlist.Add", params);
refresh();
}
示例14: idFromPlaylistItem
QVariantMap MediaPlayer2Player::Metadata() const
{
QVariantMap metaData;
// The track ID is annoying since it must result in a valid DBus object
// path, and the regex for that is, and I quote: [a-zA-Z0-9_]*, along with
// the normal / delimiters for paths.
PlaylistItem *item = Playlist::playingItem();
if (!item)
return metaData;
FileHandle playingFile = item->file();
QByteArray playingTrackFileId = idFromPlaylistItem(item);
metaData["mpris:trackid"] =
QVariant::fromValue<QDBusObjectPath>(
QDBusObjectPath(playingTrackFileId.constData()));
metaData["xesam:album"] = playingFile.tag()->album();
metaData["xesam:title"] = playingFile.tag()->title();
metaData["xesam:artist"] = QStringList(playingFile.tag()->artist());
metaData["xesam:genre"] = QStringList(playingFile.tag()->genre());
metaData["mpris:length"] = qint64(playingFile.tag()->seconds() * 1000000);
metaData["xesam:url"] = QString::fromLatin1(
KUrl::fromLocalFile(playingFile.absFilePath()).toEncoded());
if(playingFile.coverInfo()->hasCover()) {
QString fallbackFileName = KStandardDirs::locateLocal("tmp",
QString("juk-cover-%1.png").arg(item->trackId()));
QString path = fallbackFileName;
if(!QFile::exists(path)) {
path = playingFile.coverInfo()->localPathToCover(fallbackFileName);
}
metaData["mpris:artUrl"] = QString::fromLatin1(QUrl::fromLocalFile(
path).toEncoded());
}
return metaData;
}
示例15: import_tool
static void import_tool(GtkWidget *w, GTKMusicBrowser *p)
{
FileSelector *filesel = new FileSelector(p->GetContext(),"Import a Track or Playlist into My Music");
if (filesel->Run()) {
FAContext *m_context = p->GetContext();
char *returnpath = filesel->GetReturnPath();
char *filereturn = strdup_new(returnpath);
if (filereturn)
{
char *first = strtok(filereturn, "\n");
while (first) {
char *ext = m_context->player->GetExtension(first);
uint32 length = strlen(first) + 10;
char *tempurl = new char[length];
if (IsntError(FilePathToURL(first, tempurl, &length)))
{
if (ext && m_context->plm->IsSupportedPlaylistFormat(ext))
p->ImportPlaylist(tempurl);
else if (ext &&
m_context->player->IsSupportedExtension(ext))
{
PlaylistItem *plist = new PlaylistItem(tempurl);
m_context->plm->RetrieveMetaDataNow(plist);
m_context->catalog->WriteMetaDataToDatabase(tempurl,
plist->GetMetaData());
m_context->catalog->AddSong(tempurl);
delete plist;
}
}
delete [] tempurl;
delete ext;
first = strtok(NULL, "\n");
}
delete [] filereturn;
}
}
delete filesel;
}