2015-06-23 61 views
0

我想在特定時間啓動AMP(Azure Media Player)HTML5視頻以顯示視頻的特定內容。設置Azure Media Player的開始時間

什麼是不工作是時候開始。視頻始終從零點開始,然後很好地播放到最後。在js控制檯中沒有有用的通知。

我通過一些實例和文檔閱讀,這是什麼我都試過了,(注意線myPlayer.currentTime(30)):

腳本:

var myPlayer = amp('vid1', { /* Options */ 
     "nativeControlsForTouch": false, 
     autoplay: false, 
     controls: true, 
     width: "640", 
     height: "400", 
     poster: "" 
    }, 
    function() { 
     myPlayer.src([{ 
      src: "http://amssamples.streaming.mediaservices.windows.net/91492735-c523-432b-ba01-faba6c2206a2/AzureMediaServicesPromo.ism/manifest", 
      type: "application/vnd.ms-sstr+xml" 
     }]); 
     myPlayer.currentTime(30); 
     console.log('Good to go!'); 
     this.play(); // if you don't trust autoplay for some reason 

     // add an event listener 
     this.addEventListener('ended', function() { 
      console.log('Finished!'); 
     }); 
    }); 

HTML

<video id="vid1" class="azuremediaplayer amp-default-skin"> 
     <source src="" type="application/vnd.ms-sstr+xml" /> 
     <p class="amp-no-js"> 
      To view this video please enable JavaScript, and consider upgrading to a web browser that supports HTML5 video 
     </p> 
    </video> 

我已經使用下面的源來設置它。 Link to documentation I have used

回答

2

用以下代碼替換HTML視頻標籤,它將在設定的時間開始。它設置了currentTime(30)的來源;不運行。

<video id="vid1" class="azuremediaplayer amp-default-skin amp-big-play-centered" tabindex="0"> </video> 
2

根據您的情況,有兩種方法可以實現此目的。

如果你的場景是你想要在30秒開始,但給予用戶觀看時間0:00-0:30的能力,那麼在播放事件之後(源被設置之後)設置currentTime將會工作。

如果您的場景是您希望流在30秒內啓動,但您不希望觀看者看到前30秒(更像是修剪或剪輯版本,因爲可能前30秒是空白內容或者只是一個靜態緩衝器),你最好創建一個動態清單。使用動態清單,您可以調整內容的開始時間(並根據需要添加其他過濾器),以便創建更精確的開始時間,而無需創建其他資產(因爲它使用現有資產)。查看the blog瞭解更多關於動態清單的細節。

+0

我給你+1了,因爲我認爲它增加了答案的價值,但我自己回答了這個問題,一直在等待「2天設置自我答案」的限制。乾杯! –