php - build an API for streaming audio/video from GridFS mongodb -
i have tried solution given in link stream audio/video files gridfs on browser
still when use code file gets downloaded or plays default browser player. code as:
header('content-type: audio/mpeg;'); $stream = $file->getresource(); while (!feof($stream)) { echo fread($stream, 8192); }
i want solution build api can retrieve audio/video mongodb gridfs , play streaming phone application.
help urgently needed. on topic welcome.
i found way make api playing file straight mongodb gridfs in html audio video image widget. problem uses data retrieved mongodb base64 data. problem talking discussed in link:
http://davidbcalhoun.com/2011/when-to-base64-encode-images-and-when-not-to.
i hope find useful before deciding use solution using. solution follows:
$stream = $file->getresource(); $stringcoded = stream_get_contents($stream); //converts stream string data $encoded = base64_encode($stringcoded); //encodes string data base64
now have audio, video or image data encoded in base64, have echo data in 'src' portion of html5 widget.
i got solution useful blog. if need more on please go through it:
http://www.iandevlin.com/blog/2012/09/html5/html5-media-and-data-uri
any enhanced solution problem more welcome.
Comments
Post a Comment