2015-07-02 77 views
0

使用Microsoft Azure可以傳輸MP3或WAV文件嗎?使用Microsoft Azure流式傳輸MP3文件

我想要使用任何js-player播放的文件,包括從用戶想要的任何點開始播放(比如soundcloud播放器,...)。 我試圖使用Blob存儲,但那不可能,因爲它確實支持流式傳輸,所以文件必須完全下載才能跳到歌曲的某個點。

有沒有辦法讓Blob存儲成爲可能?或者我必須使用Azure媒體服務(嘗試過,但只能找到對視頻的支持)?

回答

0

這裏的問題是存儲的服務版本。我必須通過Java程序手動將其設置爲更高版本(2014-02-14)。

這是代碼。您需要azure SDK(https://github.com/Azure/azure-sdk-for-java)和slf4j,lang3和fasterxml庫。

import com.microsoft.azure.storage.*; 
import com.microsoft.azure.storage.CloudStorageAccount; 
import com.microsoft.azure.storage.blob.CloudBlobClient; 
import com.microsoft.azure.storage.ServiceProperties; 

public class storage { 

    public static void main(String[] args) { 
     CloudStorageAccount storageAccount; 
     ServiceProperties serviceProperties; 

     try { 
      storageAccount = CloudStorageAccount.parse("AccountName=<storageName>;AccountKey=<storageAccessKey>;DefaultEndpointsProtocol=http");  


      CloudBlobClient blobClient = storageAccount.createCloudBlobClient(); 

      // Get the current service properties 
      serviceProperties = blobClient.downloadServiceProperties(); 


      // Set the default service version to 2011-08-18 (or a higher version like 2012-03-01) 
      serviceProperties.setDefaultServiceVersion("2014-02-14"); 

      // Save the updated service properties 
      blobClient.uploadServiceProperties(serviceProperties); 
     } catch(Exception e) { 
      System.out.print("Exception"); 
     } 

    }; 
};