Titanium:来自数据库的视频播放器数据源

时间:2014-09-04 20:34:53

标签: titanium titanium-mobile

所以,我想把一个mp3文件放在DB blob中,然后从那里播放。

我可以看到视频对象支持blob,但看起来它是一个文件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);

此外,它支持文件或文本元素:

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

这是否意味着我可以将blob指定为字符串?

1 个答案:

答案 0 :(得分:1)

在iOS上,您可以使用媒体属性并设置Media object to play, as either a File, a Blob, or a URL.,但它更像是一个多平台属性,如网址。

所以最好的答案是:

  1. 阅读数据库并获取Blob

  2. 将Blob写入FileSystem

  3. 的临时文件
  4. 将文件路径设置为url property of VideoPlayer

  5. 我希望我的回答可以帮助你:)

相关问题