【问题标题】:How to access external Storage in Tizen Smart TVs如何访问 Tizen 智能电视中的外部存储
【发布时间】:2015-06-16 18:45:19
【问题描述】:

我需要您帮助了解如何从 Tizen 智能电视的外部 USB 存储中写入和读取文件。检测到问题就开始了

`
/**
 * Hello World Sample Project
 */
// import Label component
var Label = caph.require('ui.base.component.Label');

caph.app.addScene('main', $class({
    $extends : caph.require('ui.base.Scene'),

    // oncreate is called when the scene is created
    oncreate : function() {
        // add "Hello World"

        this.addChild(new Label({
            text : 'Hello World',
            size : [ 500, 100 ],
            position : [ 300, 400 ]
        }).setTextSize('72px').setStyle({
            backgroundColor : 'red',
            color : 'white'
        }));

        /// Here the filesystem showd show me all the storages
        tizen.filesystem.listStorages(checkCorruptedRemovableDrives);
    }
})).run();
`

这里是 Success 回调,它显示我有多少存储空间。 ` /* 成功事件处理程序 */ var checkCorruptedRemovableDrives = function(storages) {

    /// Here I will kow how much storages I have
    console.log(storages.length);

    for (var i = 0; i < storages.length; i++) {
        if (storages[i].type != "EXTERNAL")
            continue;
        if (storages[i].state == "UNMOUNTABLE")
            console.log("External drive " + storages[i].label + " is corrupted.");
    }
};
`

这是出现错误时抛出的方法,它永远不会被调用。 var checkCorruptedRemovableDrivesError = function(storages){ console.log("Error"); }

现在,控制台输出是一个简单的0,这意味着我没有存储空间(但我安装了内部的一个和两个 USB)。

有没有人遇到过这个问题或对如何解决有任何想法?

【问题讨论】:

    标签: api filesystems mount tizen samsung-smart-tv


    【解决方案1】:

    Samsung Tizen TV 始终使用“removable2”作为 USB 的标签。 所以你不需要使用 listStorage 和 getStorage。

    多个USB被区分为“removable2/sda1”、“removable2/sda2”

    tizen.filesystem.resolve("removable2", function(e){
            e.listFiles(function(r){
                for(i = 0; i < r.length; i++){
                    tizen.filesystem.resolve(r[i].path + r[i].name, function(t){
                        //You resolve USB root. Do something you want with USB.
                    }, function(t){
                        console.log("resolve error for " + r[i].path + r[i].name);
                        console.log(t);                
                    }, "rw"); //you should use rw permission, to write something in usb.
                }
            });               
        },function(e){
            console.log("removable2 resolve error");
            console.log(e);
        }, "r"); // permission should be given as r for removable2
    

    这是我制作的测试应用。您可以查看如何使用 SDK 1.5

    http://www.samsungdforum.com/SamsungDForum/ForumView/3ad8bd6023af18a7?forumID=d88a711f47dc6e9f

    此应用可在 TV 和 SDK 1.5 中运行

    【讨论】:

      【解决方案2】:

      您使用网络模拟器吗? API 在 Web 模拟器中无法正常工作。它不能很好地模拟事物。

      当我在“模拟器”中检查 listStorage 时,它​​会抛出存储列表。 但即使我可以获得存储列表,我也不能在文件系统中使用它。这是 SDK 1.4 的错误。

      SDK 1.5 将有 USB 存储测试功能,计划在一个月内发布。等一个月:(

      【讨论】:

      • 谢谢,但我正在使用真实的电视进行测试。
      • 你好。 SDK 1.5 发布。我让文件系统在 SDK 和电视上都能正常工作。 SDK无法获取状态变化监听事件,显示状态有bug,但可以正常获取文件列表。电视设备运行良好。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-02
      • 1970-01-01
      • 1970-01-01
      • 2015-08-30
      相关资源
      最近更新 更多