Nataniel Richardt
Nataniel Richardt

Reputation: 232

Play video instead of download it. Js/HTML5 not playing video with scr="myvideolink.mp4"

I have the following link:

http://cdnv2.ec.cx/RedeCanais/RedeCanais/RCServer01/videos/STHPRKT02EP01.mp4

I'm trying to embed it in an application that i'm writing in React.

I have tried using HTML5 video tag and video-react, but instead of playing the file it downloads right away... I made a test in C# (winforms) with Windows Media Player Component and it plays normally.

Here some source I've tried:

<video controls>
  <source src="http://cdnv2.ec.cx/RedeCanais/RedeCanais/RCServer01/videos/STHPRKT02EP01.mp4" type="video/mp4">
</video>

    <video src="http://cdnv2.ec.cx/RedeCanais/RedeCanais/RCServer01/videos/STHPRKT02EP01.mp4" controls>

import React from 'react';
import { Player } from 'video-react';

export default (props) => {
  return (
    <Player
      playsInline
      src="http://cdnv2.ec.cx/RedeCanais/RedeCanais/RCServer01/videos/STHPRKT02EP01.mp4"
    />
  );
};

Is there a way to play this link on the browser with only js or some client-side script?

Upvotes: 1

Views: 4001

Answers (1)

Offbeatmammal
Offbeatmammal

Reputation: 8236

curl -I http://cdnv2.ec.cx/RedeCanais/RedeCanais/RCServer01/videos/STHPRKT02EP01.mp4 shows that your server has a MIME type of video/x-flv for your video. You want it to be video/mp4

in IIS you can adjust that either with a web.config file, or:

  • Right-click the site in IIS and select Properties.
  • Select the HTTP Headers Tab.
  • Select File Types.
  • Under the MIME Map section, select New Type.
  • Type ".mp4" as the associated extension and "video/mp4" as the content type.
  • Click OK.

Upvotes: 1

Related Questions