2015-07-02 74 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"); 
     } 

    }; 
};