Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Sound or image encode base64 — Gideros Forum

Sound or image encode base64

andrecaribeandrecaribe Member
edited August 2013 in General questions
How I can read sound or image and encode to base64?

I try to use Lua implementations of base64 encode/decode but I got "stack overflow (string slice too long)"
Any idea?

Comments

  • velho, está difícil viu! vim parar logo aqui na sua pergunta! armaria
  • most probably you could wrap some C solution into plugin and that might be sufficient.

    Is there any specific reason you want to encode binary data to base64?
  • andrecaribeandrecaribe Member
    edited August 2013
    I need do this for use an API.

    Solution:

    - Import mime.lua and ltn12.lua to project from socket.lua plugin folder
    - Defines mime.lua requires ltn12.lua on Gideros Studio
    - Install socket.lua plugin on iOS and Android project normally
    local mime = require("mime")
     
    local filename = "path/to/file/filename"
    local fileHandle = io.open(filename, "rb")
    local fileString = mime.b64( fileHandle:read( "*a" ) )
    io.close( fileHandle )
     
    print(fileString)

    Likes: ar2rsawseen

    +1 -1 (+1 / -0 )Share on Facebook
  • My solution works on Gideros Player (desktop) and APK file on Android, if I try to use on Wi-fi mode causes an error:
    libs/mime.lua:13: module 'mime.core' not found:
    	no field package.preload['mime.core']
    	no file './mime/core.lua'
    	no file '/usr/local/share/lua/5.1/mime/core.lua'
    	no file '/usr/local/share/lua/5.1/mime/core/init.lua'
    	no file '/usr/local/lib/lua/5.1/mime/core.lua'
    	no file '/usr/local/lib/lua/5.1/mime/core/init.lua'
    	no file './mime/core.so'
    	no file '/usr/local/lib/lua/5.1/mime/core.so'
    	no file '/usr/local/lib/lua/5.1/loadall.so'
    	no file './mime.so'
    	no file '/usr/local/lib/lua/5.1/mime.so'
    	no file '/usr/local/lib/lua/5.1/loadall.so'
    stack traceback:
    	libs/mime.lua:13: in main chunk
    It's possible to exports others Lua files and .so libraries when I test on device on Wi-fi mode?
  • @andrecaribe I know I asked you that in other thread, but still checking.
    What version does the Gideros player display on your phone, because mime.lua was added only in 2013.06
  • Oh sorry, ok, my real problem is about Microphone lib when I test on device (wifi). In the other device Gideros Player was 2012.9.10, then ignore the above error and and consider the following:
    source/MicrophoneManager.lua:1: module 'microphone' not found:
    	no field package.preload['microphone']
    	no file './microphone.lua'
    	no file '/usr/local/share/lua/5.1/microphone.lua'
    	no file '/usr/local/share/lua/5.1/microphone/init.lua'
    	no file '/usr/local/lib/lua/5.1/microphone.lua'
    	no file '/usr/local/lib/lua/5.1/microphone/init.lua'
    	no file './microphone.so'
    	no file '/usr/local/lib/lua/5.1/microphone.so'
    	no file '/usr/local/lib/lua/5.1/loadall.so'
    stack traceback:
    	source/MicrophoneManager.lua:1: in main chunk
  • Yes probably microphone plugin is not automatically exported with the app, because in most cases it is not needed, so you need to install it manually.

    Go to your Gideros installation and open All Plugins\Microphone\bin\Android

    Then copy both folders to your project's libs folder.

    Then copy All Plugins\Microphone\source\com to your project's src\com folder.

    Then add android.permission.RECORD_AUDIO to your AndroidManifest

    Then open up your main activity and add:
    System.loadLibrary("microphone");
    and
    "com.giderosmobile.android.plugins.GMicrophone" to externalClasses array.
  • andrecaribeandrecaribe Member
    edited September 2013
    I can export the APK with plugins. I can not export the plugin (Microphone) through Gideros Studio to the device (Gideros Player) by network.
  • ar2rsawseenar2rsawseen Maintainer
    Accepted Answer
    Yes because player probably also does not contain Microphone plugin.
    But for now you can build your own Gideros player with Microphone plugin, by simply deleting assets folder inside assets folder in your current eclipse project ;)
Sign In or Register to comment.