react-native-video: How to support audio/video data comming from a blob? - react-native-video

I am using react-native-video package to play audio/video on my App. It work fine for URLs.
import Video from 'react-native-video';
<Video source={{uri: 'https://www.w3schools.com/html/mov_bbb.mp4' }}
I have some audio/video files saved in a DB as blob data. How can I display them? I tried following way, but no luck with it.
var audioURL = "data:audio/mp3;base64," + this.state.dataSource[i].contentData ;
// This content data has whats comming from db
<Video source={{uri: audioURL }}

Related

Ionic 3 get base64 audio string from recorded file

I am using cordova-plugin-media to record voice(with pause and resume features) in my ionic app for android. After I record it I need to get base64 string in order to play it using html audio tag. And the problem is: if I am trying to save recording which was paused and resumed as 3gp file('voice.3gp'), then when I use readAsDataURL method of cordova-plugin-file, I don't receive anything(the callback simply not called). If I am trying to save it as mp3 or wav file, then I receive only 1st part of the recording(before pause). I suppose that the proper audio file extension should be 3gp as this extension is used in the implementation of 'cordova-plugin-media' but then I have problems with playing this file using html audio tag. Any help is appriciated
okay, I just found out that you can use method "resolveLocalFilesystemUrl" of the cordova-plugin-file which will return you the object and inside this object there is a property "nativeURL" which can be used as a source(src) for the video tag(had to video tag instead of audio because 3gp format is actually for video)
this.file.readAsDataURL(filePathtoUpload, this.fileName)
.then((base64Audio) => {
console.log(base64Audio);
})
.catch(function (err: TypeError) {
console.log("readAsDataURL: " + err);
});
this works for me
Read this:https://ionicframework.com/docs/v3/native/base64/
It is the oficial website API of ionic. Just install that plugin and use this:
this.base64.encodeFile(this.filePath + this.fileName).then(
(base64:any) =>{
console.log('file base64 encoding: ' + base64);
});
In this post, i explain it better. I let the link here:
convert audio file to base64 in ionic 3

Getting streaming to work properly in JWPlayer

I'm trying to implement streaming with JWPlayer using the following URL: rtmp://stream.technolutions.com/vod/mp4:0447d67935584a81986a0311443a7d9c.mp4.
I'm putting this RTMP URL in the following:
<script type="text/javascript">
jwplayer("modal-videoplayer-container-1").setup({
file: "rtmp://stream.technolutions.com/vod/mp4:0447d67935584a81986a0311443a7d9c.mp4",
image: "http://placehold.it/739x554/0000cc/&text=700x450",
width: 700,
height: 450
});
</script>
I understand there's a different between Application and Stream but testing this URL inside VLC as a remote video works just fine. Any ideas?
If you are having similar problems it is possible that your SWF file could be corrupted (due to being moved/copied in an automated workflow such as Grunt or Gulp). Some aspects of JWPlayer may work but when you use a feature that's solely flash based (such as JWPlayer streaming) it will just show a blank black box where you expect your video to play.
Try including JWPlayer's cloud-hosted JS file instead of hosting it yourself to see if it solves it. Special thanks to Ethan and Cooper at JWPlayer for helping me out with this.

How to play audio file instantaneously on webpage

I want to play an audio file from server. currently i am using html audio control, but its very slow. my requirement is to play as fast as possible, almost instantaneously. what would be the best way to achieve this? reference to source would be appreciated. Thanks in advance.
The HTML5 way is here.
<audio controls>
<source src="http://media.w3.org/2010/07/bunny/04-Death_Becomes_Fur.mp4"
type='audio/mp4'>
<!-- The next two lines are only executed if the browser doesn't support MP4 files -->
<source src="http://media.w3.org/2010/07/bunny/04-Death_Becomes_Fur.oga"
type='audio/ogg; codecs=vorbis'>
<!-- The next line will only be executed if the browser doesn't support the <audio> tag-->
<p>Your user agent does not support the HTML5 Audio element.</p>
</audio>
You can also make use of javascript to get this done.
var aud = document.createElement("iframe");
aud.setAttribute('src', "http://yoursite.com/youraudio.mp4"); // replace with actual file path
aud.setAttribute('width', '1px');
aud.setAttribute('height', '1px');
aud.setAttribute('scrolling', 'no');
aud.style.border = "0px";
document.body.appendChild(aud);

Playlist file(m3u8) give another playlist file infinitely not giving any media file

I have a playlist file which give me another playlist file which also give me another playlist file, continously.
How can I play this playlist file? and Where can I found the source of video?
For example, I have a playlist file. That is
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=355670
http://slive.ytn.co.kr:1935/live/ylive_0624_1.sdp/playlist.m3u8?wowzasessionid=195968950
If I access to http://slive.ytn.co.kr:1935/live/ylive_0624_1.sdp/playlist.m3u8?wowzasessionid=195968950, it give me other playlist files.
#EXTM3U
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:894
#EXTINF:11,
media_894.ts?wowzasessionid=195968950
#EXTINF:10,
media_895.ts?wowzasessionid=195968950
#EXTINF:11,
media_896.ts?wowzasessionid=195968950
If I access to the results, it also give me playlist files.
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=373764
http://slive.ytn.co.kr:1935/live/ylive_0624_1.sdp/playlist.m3u8?wowzasessionid=1093961187
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=382539
http://slive.ytn.co.kr:1935/live/ylive_0624_1.sdp/playlist.m3u8?wowzasessionid=1566364859
etc...
Although I can play the url http://slive.ytn.co.kr:1935/live/ylive_0624_1.sdp/playlist.m3u8?wowzasessionid=195968950 in safari in my iphone, I want to play this url in my own iphone app.
How can I play m3u8 file extension by myself?
EDIT - May be a duplicate of this SO question but if you want to persist the file, you'll need to go the hard way listed below.
Easy way = Embed UIWebView in your app and initialize it with the url of the .m3u8 file. This will open up quicktime which understands m3u8 and it will play it as it downloads.
Hard way = manually create the request/responses for each part of the m3u8 session and then download each .ts file in turn from the playlist file. As you get each "chunk" of the video, write it to a file or memory, then append the next "chunk" after it. I've done this for a h.264 encoded .m4v file served as a m3u8 and it worked (my code is too ugly to paste) but the pseudocode is:
Fetch the m3u8, saving any cookies sent and any headers that may be important*
Parse the .m3u8 (the first file, with the #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=373764) and pull our the urls.
Fetch the playlist from one of the URLs in the .m3u8 file (being sure to keep any headers/cookies in the request that may be necessary)
Parse the playlist file, saving as much metadata as you need from the top part of the file, construct an absolute URL for each .ts path, then stuff it into an array.
Iterate over the array (again, being mindful of cookies/headers) and fetch the content of each .ts URL into a file.
Play the downloaded file with whichever Media Framework you choose (search SO for how to do this)
If you just need to play the files, go the easy route. If you need to persist them, you need to do the m3u8 dance.
*HTTP Scoop is invaluable for seeing how the m3u8 "protocol" works and for making sure you're request/response headers are accurate - http://tuffcode.com/
*I used vanilla NSURLConnection synchronous calls as my code was just a proof of concept, other network frameworks like AFNetworking will make this a lot easier.

youtube xml parser for iphone

I am working on iphone application which will read the following youtube page source:
view-source:http://www.youtube.com/user/danielmorcombefd
and then save the links of all the videos available on any particular youtube channel like the href node of the line below:
<h4><a class="title" href="/watch?v=ouMPBbZ2vKw&context=C2ab41ADOEgsToPDskJnhTjKl70yDQdEkLJb0So8" dir="ltr">
Can anybody suggest a source code link for youtube xml reader. Solutions are appreciate in advance
Alternate
You can also use the JSON format. You can add ?alt=json to the URL to get the JSON version of it. Then you can use JSON library. JSON library