Search code examples
titaniumtitanium-mobile

Titanium: Video player data source from database


So, i would like to put an mp3 file in a DB blob, and play it from there.

I can see that the video object supports a blob, but it appears it's a file blob?

var blobStream = Ti.Stream.createStream({ source: myBlob, mode: Ti.Stream.MODE_READ });
var newBuffer = Ti.createBuffer({ length: myBlob.length });
var bytes = blobStream.read(newBuffer);

Additionally, it supports a file or text metod:

text : StringREADONLY
UTF-8 string representation of the data in this blob.
file : Titanium.Filesystem.FileREADONLY
File object represented by this blob, or null if this blob is not associated with a file

Does this mean i can specify the blob as a string?


Solution

  • On iOS, you can use media property and set Media object to play, as either a File, a Blob, or a URL., but it is better a multiplatform property like url.

    So the best answer is:

    1. Read DB and get Blob

    2. Write Blob to temporal file at FileSystem

    3. Set File Path to url property of VideoPlayer

    I hope my answer helps you :)