John
John

Reputation: 21

How to remove CC button by default from embedded Vimeo player (in vimeo api disabling texttracks option)

I've created an embed preset and set it as the default preset for all videos I upload on Vimeo. This preset removes everything but the play button. I have embedded the video that is the basis for the preset and it works correctly.

However, when I embed new videos uploaded with this preset as default, the CC button appears as well. This means that for these videos, the embedded player has the play button and CC button and nothing else.

Interestingly, I can't even manually remove the CC button for these videos under "https://vimeo.com/manage/videos/{video_id}/customize". All options are already turned off for that area, as I would expect because of the default preset, but the CC button is still there.

I am progammatically uploading these new videos using the Python client:

client.upload(file_name, data={
      'name': title})

I have a Pro account. What am I missing?

Upvotes: 2

Views: 1345

Answers (1)

pbaranski
pbaranski

Reputation: 24952

FIRST - correcting already added captions (in API its call: texttracks)

Documentation: https://developer.vimeo.com/api/upload/texttracks#uploading-a-text-track-step-1

Python example

You need to have two items:

  1. video JSON object (to get uri to the video: video['uri']) - or directly change video['uri'] in this example to uri you have
  2. Auth token (as auth_token)

How final function will look:

video = {"uri": "/videos/0000000"}
set_video_texttracks_inactive(video)

Get active texttracks for video:

def get_texttracks_uris(video):
    texttracks_uris = []
    video_url_tt = f"https://api.vimeo.com/{video['uri']}/texttracks"

    headers = {
                'Content-Type': 'application/json',
                'Authorization': f'Bearer {auth_token}'
            }
    response = requests.request("GET", video_url_tt, headers=headers)
    data = json.loads(response.text)

    for textrack in data['data']:
        if textrack['active']:
            texttracks_uris.append(textrack['uri'])
    print(f"Found: {len(texttracks_uris)} texttracks for video {video['uri']}")
    return texttracks_uris

Disable all texttracks example function:

def set_video_texttracks_inactive(video):
    texttrack_uris = get_texttracks_uris(video)

    if not texttrack_uris:
        print(f"No TEXTTRACKS uris found for video {video['uri']}")
    else:
        for texttrack_uri in texttrack_uris:
            url = f"https://api.vimeo.com/{texttrack_uri}"

            payload = "{ \r\n \"active\": false \r\n}"

            headers = {
                'Content-Type': 'application/json',
                'Authorization': f'Bearer {auth_token}'
            }

            response = requests.request("PATCH", url, headers=headers, data=payload)

            message = 'SETTING VIDEO TEXTTRACKS TO FALSE \n'
            message += f'resp: {response.status_code} \n'
            message += f'url: {url} \n'
            print(message)

SECOND - is good to disable that feature in your account:

https://vimeo.zendesk.com/hc/en-us/articles/224968828-Captions-and-subtitles#h_01FTGQWR58905Z6HGPS6F6KYSS

  1. Navigate to the Upload defaults section of your account settings.
  2. By default, “Allow viewers to enable automatically generated captions” will be checked. Uncheck the box to turn this off.
  3. Click Save.
  4. Your videos will still be transcribed on the backend, but the captions will not be available to your viewers on future uploads unless you enable them on a specific video (read below).

Upvotes: 1

Related Questions