反应视频渲染

时间:2015-10-29 11:27:44

标签: javascript video reactjs instagram redux

我在回复视频时遇到问题。它以某种方式重叠视频。在源代码中它是正确的,但在页面查看中它不正确。它只发生在一个视频中。每次它发生在不同的视频等

签入对象检查员时。我有工作的东西在PHP,但有反应正在做这个渲染问题我不知道它的浏览器渲染问题或反应。我在所有浏览器上尝试过并做同样的事情。

Rendering problem on image

第二行和第二列中的视频来源:

<a href="https://instagram.com/p/9QfapSvLHD/" target="_blank" class="life-one-photo table-cell modal" data-reactid=".0.0.$5">
   <video loop="" autoplay="" muted="" poster="https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/e15/12145465_444078379115659_399268826_n.jpg" class="life-one-photo-video" data-reactid=".0.0.$5.0">
     <source src="https://scontent.cdninstagram.com/hphotos-xaf1/t50.2886-16/12136722_988951267856293_201072634_n.mp4" data-reactid=".0.0.$5.0.0">
  </video>
</a>

第二行和第四列的来源:

<a href="https://instagram.com/p/9HYbUYvLIT/" target="_blank" class="life-one-photo table-cell modal" data-reactid=".0.0.$7">
  <video loop="" autoplay="" muted="" poster="https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/e15/12142112_830542177065598_1671839696_n.jpg" class="life-one-photo-video" data-reactid=".0.0.$7.0">
    <source src="https://scontent.cdninstagram.com/hphotos-xaf1/t50.2886-16/12125856_1718151458404599_30943699_n.mp4" data-reactid=".0.0.$7.0.0">
  </video>
</a>

你可以看到来源不同但视频仍然相同,我不知道这里发生了什么。另外如果使用react而不是在php中渲染时需要更多的cpu。我有相同的东西由PHP呈现,它的效果很好, React片段代码创建帖子:

export default class Post extends Component {
  render() {
    const data = this.props.image.type === 'video' ?
      <video loop autoPlay muted poster={this.props.image.source} className="life-one-photo-video">
        <source src={this.props.image.sourceVideo}/>
      </video> :

    <img src={this.props.image.source} className="life-one-photo-img"/>

    return (
      <a href={this.props.image.link} target="_blank" className="life-one-photo table-cell modal">
        {data}
      </a>
    );
  }
}

当只有图像不是视频时,一切正常,但视频是在页面等多个相同的视频做奇怪的事情..

您可以查看来源并自行测试: https://github.com/Huvik/InstagramScroll

1 个答案:

答案 0 :(得分:5)

我修好了,

反应不要更新

console.log('script.js loaded');

chrome.runtime.onMessage.addListener(
  function(request, sender, sendResponse) {
    debugger // This never gets triggered
    console.log(sender.tab ?
                "from a content script:" + sender.tab.url :
                "from the extension");
    if (request.greeting == "hello")
      sendResponse({farewell: "goodbye"});
  });

应该只有

 <video> from <source>

然后反应改变视频源