如何在Youtube嵌入链接中禁用Youtube标题

时间:2014-04-14 20:42:32

标签: javascript youtube video.js closed-captions

在youtube上创建嵌入式链接时,默认情况下标题为on。有没有办法在嵌入youtube链接时禁用字幕或关闭它们?

documentation表示:

Make captions automatically appear for an embedded video by adding "&cc_load_policy=1" to the video's embed code.

我需要相反的方式。 我试图使用&cc_load_policiy=0,但这不起作用。我还发现this问题,但没有一个答案似乎有效。

我也在使用VideoJS。所以也许有办法通过它......

由于

2 个答案:

答案 0 :(得分:4)

使用与import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.concurrent.ThreadLocalRandom; /** * Created by Gaute on 1/30/2017. */ public class Assignment03GUI extends JFrame implements ActionListener{ ArrayList<JTextField> txtfeltNummer = new ArrayList<JTextField>(); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenu newGame = new JMenu("New Game"); JMenuItem easy = new JMenuItem("Easy"); JMenuItem medium = new JMenuItem("Medium"); JMenuItem hard = new JMenuItem("Hard"); JMenuItem deleteGame = new JMenuItem("Delete Game"); public Assignment03GUI() { JFrame sudokuWindow = new JFrame(); sudokuWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); sudokuWindow.setTitle("Sudoku"); sudokuWindow.setLayout(new GridLayout(9, 0)); sudokuWindow.setSize(1000,1000); menuBar.add(fileMenu); fileMenu.add(newGame); fileMenu.add(deleteGame); newGame.add(easy); newGame.add(medium); newGame.add(hard); sudokuWindow.setJMenuBar(menuBar); JTextField tekstfelt; //Deklarer variabelen så den kan brukes utenfor for løkka for (int i = 0; i < 81; i++) { tekstfelt = new JTextField(); //---------------------------------------------------------This test < Just want to remove that one felt user wrote in tekstfelt.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String text = ((JTextField) e.getSource()).getText(); try{ Integer.parseInt(text); System.out.println("An integer"); } catch (NumberFormatException e2) { for (JTextField felt : txtfeltNummer) { felt.setText(""); felt.setEditable(true); } JOptionPane.showMessageDialog(null,"Ugyldig, ikke et tall"); } } }); tekstfelt.setSize(100,100); tekstfelt.putClientProperty("id ", Integer.valueOf(i)); txtfeltNummer.add(tekstfelt); sudokuWindow.add(tekstfelt); } easy.addActionListener(this); medium.addActionListener(this); hard.addActionListener(this); deleteGame.addActionListener(this); sudokuWindow.setVisible(true); } @Override public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (source.equals(easy) || source.equals(medium) || source.equals(hard)) { for (JTextField felt : txtfeltNummer) { felt.setText(randomNumber(1, 9)); felt.setEditable(true); int removeNumbers = Integer.parseInt(randomNumber(0, 3)); if (source.equals(easy) && removeNumbers == 0) { felt.setText(""); } else if (source.equals(medium) && removeNumbers <= 1) { felt.setText(""); } else if (source.equals(hard) && removeNumbers <= 2) { felt.setText(""); } else { felt.setEditable(false); } } } if (e.getSource().equals(deleteGame)) { System.out.println("Delete Game"); for (JTextField felt : txtfeltNummer){ felt.setText(""); felt.setEditable(true); } } } public static String randomNumber(int min, int max) { int randomNum = ThreadLocalRandom.current().nextInt(min, max + 1); String randomNumString = Integer.toString(randomNum); return randomNumString; } } 相同的逻辑,并将值设置为iv_load_policy

例如:

3

此外,它适用于嵌入式视频的JS API。

答案 1 :(得分:1)

  

cc_load_policy(支持的播放器:AS3,AS2)值:1。默认为   根据用户偏好。设置为1将导致隐藏字幕   默认显示,即使用户关闭了字幕。

Reference

不幸的是,我不认为这是可能的,因为它是用户偏好。 cc_load_policy指的是禁用/启用播放器的切换按钮(仅限AS3,AS2播放器)。由于VideoJS基于HTML5,我想象cc_load_policy也无法供您使用。