mirror of
				https://github.com/TeamPiped/Piped.git
				synced 2024-08-14 23:57:27 +00:00 
			
		
		
		
	replace deprecated function: addTextTrack -> addTextTrackAsync
This commit is contained in:
		
							parent
							
								
									4e1c7267a8
								
							
						
					
					
						commit
						caf3b20e58
					
				
					 1 changed files with 148 additions and 135 deletions
				
			
		| 
						 | 
					@ -1,7 +1,12 @@
 | 
				
			||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <div class="uk-container-expand">
 | 
					  <div class="uk-container-expand">
 | 
				
			||||||
    <div data-shaka-player-container ref="container">
 | 
					    <div data-shaka-player-container ref="container">
 | 
				
			||||||
            <video data-shaka-player autoplay style="width: 100%; height: 100%" ref="videoEl"></video>
 | 
					      <video
 | 
				
			||||||
 | 
					        data-shaka-player
 | 
				
			||||||
 | 
					        autoplay
 | 
				
			||||||
 | 
					        style="width: 100%; height: 100%"
 | 
				
			||||||
 | 
					        ref="videoEl"
 | 
				
			||||||
 | 
					      ></video>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
| 
						 | 
					@ -33,13 +38,13 @@ export default {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      const dash = require("@/utils/DashUtils.js").default.generate_dash_file_from_formats(
 | 
					      const dash = require("@/utils/DashUtils.js").default.generate_dash_file_from_formats(
 | 
				
			||||||
        streams,
 | 
					        streams,
 | 
				
			||||||
                this.video.duration,
 | 
					        this.video.duration
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (noPrevPlayer)
 | 
					      if (noPrevPlayer)
 | 
				
			||||||
        shaka
 | 
					        shaka
 | 
				
			||||||
                    .then(shaka => shaka.default)
 | 
					          .then((shaka) => shaka.default)
 | 
				
			||||||
                    .then(shaka => {
 | 
					          .then((shaka) => {
 | 
				
			||||||
            this.shaka = shaka;
 | 
					            this.shaka = shaka;
 | 
				
			||||||
            shaka.polyfill.installAll();
 | 
					            shaka.polyfill.installAll();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -55,7 +60,7 @@ export default {
 | 
				
			||||||
        videoEl.addEventListener("timeupdate", () => {
 | 
					        videoEl.addEventListener("timeupdate", () => {
 | 
				
			||||||
          if (this.sponsors && this.sponsors.segments) {
 | 
					          if (this.sponsors && this.sponsors.segments) {
 | 
				
			||||||
            const time = videoEl.currentTime;
 | 
					            const time = videoEl.currentTime;
 | 
				
			||||||
                        this.sponsors.segments.map(segment => {
 | 
					            this.sponsors.segments.map((segment) => {
 | 
				
			||||||
              if (!segment.skipped) {
 | 
					              if (!segment.skipped) {
 | 
				
			||||||
                const end = segment.segment[1];
 | 
					                const end = segment.segment[1];
 | 
				
			||||||
                if (time >= segment.segment[0] && time < end) {
 | 
					                if (time >= segment.segment[0] && time < end) {
 | 
				
			||||||
| 
						 | 
					@ -82,20 +87,24 @@ export default {
 | 
				
			||||||
      //TODO: Add sponsors on seekbar: https://github.com/ajayyy/SponsorBlock/blob/e39de9fd852adb9196e0358ed827ad38d9933e29/src/js-components/previewBar.ts#L12
 | 
					      //TODO: Add sponsors on seekbar: https://github.com/ajayyy/SponsorBlock/blob/e39de9fd852adb9196e0358ed827ad38d9933e29/src/js-components/previewBar.ts#L12
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    setPlayerAttrs(player, videoEl, dash, shaka) {
 | 
					    setPlayerAttrs(player, videoEl, dash, shaka) {
 | 
				
			||||||
            player.load("data:application/dash+xml;charset=utf-8;base64," + btoa(dash)).then(() => {
 | 
					      player
 | 
				
			||||||
                this.video.subtitles.map(subtitle => {
 | 
					        .load("data:application/dash+xml;charset=utf-8;base64," + btoa(dash))
 | 
				
			||||||
                    player.addTextTrack(
 | 
					        .then(() => {
 | 
				
			||||||
 | 
					          this.video.subtitles.map((subtitle) => {
 | 
				
			||||||
 | 
					            player.addTextTrackAsync(
 | 
				
			||||||
              subtitle.url,
 | 
					              subtitle.url,
 | 
				
			||||||
              subtitle.code,
 | 
					              subtitle.code,
 | 
				
			||||||
              "SUBTITLE",
 | 
					              "SUBTITLE",
 | 
				
			||||||
              subtitle.mimeType,
 | 
					              subtitle.mimeType,
 | 
				
			||||||
              null,
 | 
					              null,
 | 
				
			||||||
                        subtitle.name,
 | 
					              subtitle.name
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
          });
 | 
					          });
 | 
				
			||||||
          if (localStorage) videoEl.volume = localStorage.getItem("volume") || 1;
 | 
					          if (localStorage) videoEl.volume = localStorage.getItem("volume") || 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                const ui = this.ui || (this.ui = new shaka.ui.Overlay(player, this.$refs.container, videoEl));
 | 
					          const ui =
 | 
				
			||||||
 | 
					            this.ui ||
 | 
				
			||||||
 | 
					            (this.ui = new shaka.ui.Overlay(player, this.$refs.container, videoEl));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          const config = {
 | 
					          const config = {
 | 
				
			||||||
            overflowMenuButtons: ["quality", "captions", "playback_rate"],
 | 
					            overflowMenuButtons: ["quality", "captions", "playback_rate"],
 | 
				
			||||||
| 
						 | 
					@ -110,7 +119,11 @@ export default {
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    onKeyPress(e) {
 | 
					    onKeyPress(e) {
 | 
				
			||||||
            if (document.activeElement.tagName === "INPUT" && document.activeElement.type === "text") return;
 | 
					      if (
 | 
				
			||||||
 | 
					        document.activeElement.tagName === "INPUT" &&
 | 
				
			||||||
 | 
					        document.activeElement.type === "text"
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
      const videoEl = this.$refs.videoEl;
 | 
					      const videoEl = this.$refs.videoEl;
 | 
				
			||||||
      switch (e.code) {
 | 
					      switch (e.code) {
 | 
				
			||||||
        case "KeyF":
 | 
					        case "KeyF":
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue