示例#1
0
void Media::setImage(const std::shared_ptr<Image>& image, Dbo::Transaction& transaction) const
{
  transaction.session().execute( "DELETE FROM media_attachment WHERE media_id = ? AND type = 'preview'" ).bind( uid() );
  MediaAttachment *fullAttachment = MediaAttachment::image("full", uid(), *image );
  MediaAttachment *thumbnailAttachment = MediaAttachment::image("thumbnail", uid(), *image->scaled(IMAGE_SIZE_THUMB, 60));
  MediaAttachment *playerAttachment = MediaAttachment::image("player", uid(), *image->scaled(IMAGE_SIZE_PLAYER) );
  transaction.session().add( fullAttachment );
  transaction.session().add( thumbnailAttachment );
  transaction.session().add( playerAttachment );
}
示例#2
0
WString Media::title(Dbo::Transaction& transaction) const
{
  MediaPropertiesPtr properties = transaction.session().find<MediaProperties>().where("media_id = ?").bind(uid());
  if(!properties || properties->title().empty())
    return WString::fromUTF8(filename());
  return WString::fromUTF8(properties->title());
}
示例#3
0
void SessionInfo::endStale(Dbo::Transaction& transaction)
{
  transaction.session().execute("UPDATE session_info SET session_ended = ? WHERE session_id <> ? AND session_ended IS NULL")
    .bind(WDateTime::currentDateTime().toPosixTime())
    .bind(wApp->sessionId())
  ;
}
示例#4
0
Dbo::ptr< MediaAttachment > Media::preview(Dbo::Transaction& transaction, Media::PreviewSize size ) const
{
  string previewSize;
  switch(size) {
    case Media::PreviewFull:
      previewSize="full"; break;
    case Media::PreviewPlayer:
      previewSize="player"; break;
    case Media::PreviewThumb:
      previewSize="thumbnail"; break;
  }
  return transaction.session().find<MediaAttachment>().where("media_id = ? AND type = 'preview' AND name = ?")
    .bind(uid()).bind(previewSize);
}
示例#5
0
MediaPropertiesPtr Media::properties(Dbo::Transaction& transaction) const
{
  return transaction.session().find<MediaProperties>().where("media_id = ?").bind(uid()).resultValue();
}
示例#6
0
long Media::subtitles_count(Dbo::Transaction& transaction) const
{
  return transaction.session().query<long>("select count(*) from media_attachment").where("media_id = ? AND type = 'subtitles'").bind(uid()).resultValue();
}
示例#7
0
Dbo::collection<MediaAttachmentPtr> Media::subtitles(Dbo::Transaction& transaction) const
{
  return transaction.session().find<MediaAttachment>().where("media_id = ? AND type = 'subtitles'").bind(uid()).resultList();
}