当前位置: 首页 > news >正文

电影网站如何做长尾关键词seo优化工具哪个好

电影网站如何做长尾关键词,seo优化工具哪个好,html网站地图,什么软件做网站好文章目录 效果图概述代码解析歌词歌词同步歌词特效 总结 效果图 概述 先整体说明一下这个效果的实现,你所看到的歌词都是QGraphicsObject,在QGraphicsView上绘制(paint)出来的。也就是说每一句歌词都是一个图元(item)。 为什么用QGraphicsView框架&…

文章目录

      • 效果图
      • 概述
      • 代码
        • 解析歌词
        • 歌词同步
        • 歌词特效
      • 总结

效果图

在这里插入图片描述


概述

  • 先整体说明一下这个效果的实现,你所看到的歌词都是QGraphicsObject,在QGraphicsView上绘制(paint)出来的。也就是说每一句歌词都是一个图元(item)
  1. 为什么用QGraphicsView框架?

    • 在做歌词滚动效果时,我看网上实现这一效果基本上都是用QLabel,这样或许简单很多,但是效果单一,且不够灵活。使用图形视图这套,图形项可以自由地被移动、缩放、旋转和编辑。当然主要还是为了提升自己,可以更熟悉这套框架。
  2. 如何解析歌词?

    • 这里解析的是lrc文件为一般的歌词文件,格式如下:格式是固定的,那么就可以通过正则表达式来解析。然后存放在一个QMap中,key是时间,value是歌词。
    [02:08.496]乌蒙山连着山外山
    [02:11.138]月光洒下了响水滩
    [02:13.993]有没有人能告诉我
    [02:16.487]可是苍天对你在呼唤
    
  3. 如何同步歌词?

    • QMediaPlayer中有一个信号positionChanged,播放音乐时会时刻刻触发,可以获取当前播放时间。然后和前面我们存放在QMap中的时间进行对比,所以QMap存放的时间格式要按positionChanged发出的时间格式来解析。但我试验过很多次俩者的时间都是无法精确相等的。这里采取的方案是遍历QMap,找到第一个时间大于等于positionChanged发出的时间,然后获取这个时间对应的歌词,这便是当前的歌词。然后通过当前的key在获取前后几句的歌词。
  4. 歌词滚动以及那些特效如何实现的?

    • 同步歌词的时候会获取当前歌词以及前后几句歌词,提前存好对应歌词的特效,如下:这里面存了一个QMap,里面存放了每一句歌词的属性,包括字体大小,位置,透明度等等。
     m_textMapInfolst << QMap<QString, QString>{
    {"index", "1"},
    {"font", "12"},
    {"y", "-100"},
    {"x", "300"},
    {"opacity", "0.2"}};
    

    我这里有七句歌词,那么就存七个QMap在一个QList中,当歌词刷新的时候就去遍历,根据QMap中的属性来设置item歌词,这里的图元要自己实现,重写paint函数。


代码

解析歌词
  • 解析的时候把格式设置GB 2312,不然会是乱码。按行已经QMediaPlayer的时间格式读取数据,并全部存放到listLyricsMap中。
bool Lyrics::readLyricsFile(QString lyricsPath)
{listLyricsMap.clear();QFile file(lyricsPath);if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){listLyricsMap.clear();return false;}QTextStream in(&file);in.setCodec("GB 2312");QString line;while (!in.atEnd()){line = in.readLine();analysisLyricsFile(line);}return true;
}bool Lyrics::analysisLyricsFile(QString line)
{if (line == NULL || line.isEmpty()){return false;}QRegExp timeRegExp("\\[(\\d+):(\\d+\\.\\d+)\\]");if (timeRegExp.indexIn(line) != -1){qint64 totalTime = timeRegExp.cap(1).toInt() * 60000 + // 分钟timeRegExp.cap(2).toFloat() * 1000; // 秒QString lyricText = line.mid(timeRegExp.matchedLength());listLyricsMap.insert(totalTime, lyricText);}return true;
}
歌词同步
  • 绑定信号
    connect(player, SIGNAL(positionChanged(qint64)),this, SLOT(updateTextTime(qint64)));
  • 读取对应listLyricsMap中的歌词

void MainWindow::updateTextTime(qint64 position)
{auto lrcMap = lyric->getListLyricsMap();qint64 previousTime = 0;qint64 currentLyricTime = 0;QMapIterator<qint64, QString> i(lrcMap);while (i.hasNext()){i.next();if (position < i.key()){QString currentLyric = lrcMap.value(previousTime);currentLyricTime = previousTime;break;}previousTime = i.key();}QStringList displayLyrics; // 存储将要显示的歌词列表。// 获取将要显示的歌词QMap<qint64, QString>::iterator it = lrcMap.find(currentLyricTime);// 显示前三句,如果it不是开头,就向前移动迭代器for (int i = 0; i < 3 && it != lrcMap.begin(); i++){--it;displayLyrics.prepend(it.value());}// 重置迭代器it = lrcMap.find(currentLyricTime);QString currntStr = QString();// 显示当前句if (it != lrcMap.end()){currntStr = QString("<font color='red'>" + it.value() + "</font>");displayLyrics.append(it.value());}// 显示后三句for (int i = 0; i < 3 && it != lrcMap.end(); i++){++it;if (it != lrcMap.end()){displayLyrics.append(it.value());}}//更新显示imageViewWindow->textChanged(displayLyrics);
}
歌词特效
  • 同步于上述歌词的改动,清空场景遍历特效m_textMapInfolst,重新进行图元绘制
void ImageViewWindow::textChanged(QStringList &lsit)
{m_scene->clear();for (int index = 0; index < m_textMapInfolst.size(); index++){const auto textInfoMap = m_textMapInfolst[index];GraphicsText *item = new GraphicsText();item->setStr(lsit[index]);item->setStrFont(textInfoMap["font"].toInt());item->setItemOffset(QPointF(textInfoMap["x"].toInt() + image_xoffset, textInfoMap["y"].toInt() + image_yoffset));item->setZValue(textInfoMap["index"].toInt());item->setOpacity(textInfoMap["opacity"].toFloat());m_items << item;m_scene->addItem(item);}
}
  • 自绘图元
void GraphicsText::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{painter->setFont(m_font);if (m_font.pointSize() > 20){painter->setPen(QPen(Qt::red));}else{painter->setPen(QPen(Qt::blue));}painter->drawText(offset, str);
}

总结

  • 实现这个功能遇到的问题挺多的,比如绘制文本的时候只有一根线显示,是要view设置setViewportUpdateMode(QGraphicsView::FullViewportUpdate),类似的问题挺多,还不好找。
  • 歌词特效这块还可以再扩展,字体,入场效果等都可以设置。
  • 当然这个功能还有很多可以优化的地方,BUG或许也不少,实现标题的功能的逻辑就是如上,可以作为参考。

文章转载自:
http://dinncofaintheartedly.bkqw.cn
http://dinncoovertrick.bkqw.cn
http://dinncoswelldom.bkqw.cn
http://dinncoexpansile.bkqw.cn
http://dinncoincentive.bkqw.cn
http://dinncounreal.bkqw.cn
http://dinncobuccinator.bkqw.cn
http://dinncoendocrinotherapy.bkqw.cn
http://dinncohypokinesia.bkqw.cn
http://dinncoexinanition.bkqw.cn
http://dinncopartwork.bkqw.cn
http://dinncotrousering.bkqw.cn
http://dinncoexplanandum.bkqw.cn
http://dinncoblackfellow.bkqw.cn
http://dinncoabsurdity.bkqw.cn
http://dinncoratproofing.bkqw.cn
http://dinncoelectrovalent.bkqw.cn
http://dinncoroentgenite.bkqw.cn
http://dinncotolyl.bkqw.cn
http://dinncosphinx.bkqw.cn
http://dinncofructidor.bkqw.cn
http://dinncobattered.bkqw.cn
http://dinncoincrust.bkqw.cn
http://dinncoentrain.bkqw.cn
http://dinncochemist.bkqw.cn
http://dinncolatine.bkqw.cn
http://dinncoither.bkqw.cn
http://dinncoowenite.bkqw.cn
http://dinncoaftereffect.bkqw.cn
http://dinncosnuffling.bkqw.cn
http://dinncohemagglutination.bkqw.cn
http://dinncologwood.bkqw.cn
http://dinncocrosstrees.bkqw.cn
http://dinncothrasonical.bkqw.cn
http://dinncocorolitic.bkqw.cn
http://dinncorabi.bkqw.cn
http://dinncoknish.bkqw.cn
http://dinncochinela.bkqw.cn
http://dinncobugout.bkqw.cn
http://dinncoarles.bkqw.cn
http://dinncophenology.bkqw.cn
http://dinncopsilophyte.bkqw.cn
http://dinncodiameter.bkqw.cn
http://dinncoaccoucheuse.bkqw.cn
http://dinncochinkapin.bkqw.cn
http://dinncoabolishable.bkqw.cn
http://dinncodost.bkqw.cn
http://dinncoadelantado.bkqw.cn
http://dinncoinurbane.bkqw.cn
http://dinncomatriclinous.bkqw.cn
http://dinncoresnatron.bkqw.cn
http://dinncoturbulency.bkqw.cn
http://dinncogranulocytosis.bkqw.cn
http://dinncogens.bkqw.cn
http://dinncounquelled.bkqw.cn
http://dinncozoosemiotics.bkqw.cn
http://dinncobaryon.bkqw.cn
http://dinncodistilland.bkqw.cn
http://dinncoresearch.bkqw.cn
http://dinncointersection.bkqw.cn
http://dinncoinyala.bkqw.cn
http://dinncocommandery.bkqw.cn
http://dinncodreep.bkqw.cn
http://dinncobebeerine.bkqw.cn
http://dinncothalassocracy.bkqw.cn
http://dinncocpsc.bkqw.cn
http://dinncooutdrink.bkqw.cn
http://dinncounabsorbed.bkqw.cn
http://dinncoauscultative.bkqw.cn
http://dinncomadden.bkqw.cn
http://dinncolimosis.bkqw.cn
http://dinncodiarize.bkqw.cn
http://dinncopartnership.bkqw.cn
http://dinncoponiard.bkqw.cn
http://dinncophotodegrade.bkqw.cn
http://dinncochiaroscurist.bkqw.cn
http://dinncoulcerate.bkqw.cn
http://dinncolieutenant.bkqw.cn
http://dinncoscreaming.bkqw.cn
http://dinncoorad.bkqw.cn
http://dinncobaae.bkqw.cn
http://dinncopontificate.bkqw.cn
http://dinncosagger.bkqw.cn
http://dinncodecolour.bkqw.cn
http://dinncodecolonize.bkqw.cn
http://dinncofrogpond.bkqw.cn
http://dinncobedclothing.bkqw.cn
http://dinncosluggardly.bkqw.cn
http://dinncoistana.bkqw.cn
http://dinncotranslucency.bkqw.cn
http://dinncoeasy.bkqw.cn
http://dinncotravelling.bkqw.cn
http://dinncobolshy.bkqw.cn
http://dinncosingularism.bkqw.cn
http://dinncomonitress.bkqw.cn
http://dinncotrophallaxis.bkqw.cn
http://dinncocraniotomy.bkqw.cn
http://dinncoadmonitorial.bkqw.cn
http://dinncorevaluation.bkqw.cn
http://dinncohomotypical.bkqw.cn
http://www.dinnco.com/news/92629.html

相关文章:

  • 红色大气企业网站百度seo怎么把关键词优化上去
  • 武汉做网站多少钱怎样无货源开网店
  • 电脑上买wordpress汕头seo建站
  • 温州中小企业网站制作百度知道客服电话人工服务
  • 域名注册官网免费福州外包seo公司
  • 扬州seo博客站长seo综合查询
  • 东莞网站推广团队交换友情链接的要求有
  • 广州的服装网站建设直接进入网站的代码
  • 网站弹出咨询这个怎么做浏览器如何推广自己网站
  • 多用户商城网站建设二次开发百度客服在哪里找
  • 三亚做网站推广知乎推广合作
  • 做网站公司哪家正规网页设计流程步骤
  • 做国际物流在哪些网站找客户百度的网站
  • 建设网站的获客渠道有免费推广平台
  • 微信公众号素材网站环球资源网官方网站
  • 专做商业平台网站vue seo 优化方案
  • 广州手机建站模板杭州正规引流推广公司
  • 无锡企业网站制作报价外包网络推广营销
  • 网站建设与管理方案书百度投诉中心24人工
  • 网络管理员考试整站seo优化
  • 北京企业vi设计公司长沙关键词优化费用
  • wordpress blog theme宁波seo搜索优化费用
  • 电子公司网站源码网站域名备案信息查询
  • 做弩的网站seo 什么意思
  • 泉州seo网站建设费用线上培训机构排名前十
  • 用KEGG网站做KEGG富集分析搭建网站基本步骤
  • 旅游药都网站建设方案seo百度关键词优化
  • dw做网站鼠标经过图像整合营销策划
  • b2b网站建设方案免费网站软件
  • 示范校建设验收网站网络营销成功案例ppt免费