首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在我的开发android应用程序上下载DRM文件

在我的开发android应用程序上下载DRM文件
EN

Stack Overflow用户
提问于 2012-09-10 17:33:25
回答 1查看 3.5K关注 0票数 0

我是android开发的新手。

我创建了自动下载的应用程序,

每次下载都能正常工作,并保存在我的SD卡上,但drm文件无法在设备上打开。

我自己解释,我尝试下载扩展名为dd\dm的文件,如果常规浏览器下载了dd\dm文件,设备会将其提取到dcf扩展名。

我的应用不能做到这一点。我通知说如果我的设备重启,一切都是正确的,实际上设备将这个文件的扩展名改为dcf,我可以播放这首歌,如果我没有重启到设备,文件的扩展名仍然是.dd.dm

mt内容类型为: application/vnd.oma.drm.message

有人知道我有多需要照顾吗??

这是我的代码.....

代码语言:javascript
复制
class DownloadFileFromURL extends AsyncTask<String, String, String> {

    /**
     * Before starting background thread
     * Show Progress Bar Dialog
     * */
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        showDialog(progress_bar_type);
    }

    /**
     * Downloading file in background thread
     * */
    @Override
    protected String doInBackground(String... f_url) {
        int count;
        try {

            URL url = new URL(f_url[0]);
            URLConnection conection = url.openConnection();
            conection.getContent();
            conection.connect();
            // getting file length
            int lenghtOfFile = conection.getContentLength();

            // Insert Information Of File to Array
            getCurrentArray()[index].setSizeOfFile(OrangeFile.convertToStringRepresentation(lenghtOfFile));
            getCurrentArray()[index].setMimeOfFile(conection.getContentType());

            // input stream to read file - with 8k buffer
            InputStream input = new BufferedInputStream(url.openStream(), 8192);

            // Output stream to write file
            OutputStream output = new FileOutputStream(mPath + getCurrentArray()[index].getNameOfFile() + "." + getCurrentArray()[index].getExtOfFile());


            byte data[] = new byte[1024];

            long total = 0;

            while ((count = input.read(data)) != -1) {
                total += count;
                // publishing the progress....
                // After this onProgressUpdate will be called
                publishProgress(""+(int)((total*100)/lenghtOfFile));

                // writing data to file
                output.write(data, 0, count);
            }

            // flushing output
            output.flush();

            // closing streams
            output.close();
            input.close();


        } catch (Exception e) {
            Log.e("Error: ", e.getMessage());
        }

        return null;
    }
EN

回答 1

Stack Overflow用户

发布于 2013-07-05 14:42:47

虽然这是一个古老的问题,但不确定你是否已经得到了答案。下面是如何克服这个问题。

首先,您不能通过文件连接接口下载".dm“和".dd”文件,尽管您可以成功下载它们,但不能直接使用它们。

检查此http://www.developer.nokia.com/Community/Wiki/Saving_and_reading_DRM-protected_files_using_FileConnection_API_and_Mobile_Media_API

当您的设备操作系统对SD卡进行彻底的内存扫描时,".dm“文件会自动转换为".dcf”。如果您只是卸载并重新挂载SD卡,那么文件也会被转换,而不必重新启动设备。

那么如何在不重启设备的情况下下载这些文件以便立即使用。

如以上链接所述,您只能通过HTTP (在浏览器中)或彩信下载受保护的内容。

因此,在你的服务器上创建一个带有指向".dm“文件的url的意图,并启动它。浏览器将捕获url并下载文件,并在下载完成后立即自动将其转换为".dcf“。

希望这能有所帮助。

编辑:您可以在通过文件连接API下载文件后显式调用媒体扫描器,方法是创建一个带有"ACTION_MEDIA_SCANNER_SCAN_FILE“操作的intent并发送广播。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12348920

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档