使用Microsoft Azure流式传输MP3文件

时间:2015-07-02 14:02:05

标签: azure stream blob mp3 storage

是否可以使用Microsoft Azure流式传输MP3或WAV文件?

我想拥有可以与任何js-player一起播放的文件,包括从用户想要的任何点开始播放(如soundcloud播放器......)。 我尝试使用Blob存储,但这不可能,因为它支持流式传输,因此必须完全下载文件才能跳转到歌曲的某一点。

有没有办法让Blob存储成为可能?或者我是否必须使用Azure媒体服务(试过但只找到视频支持)?

1 个答案:

答案 0 :(得分: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");
        }

    };
};
相关问题