Deprecated: Non-static method Joomla\CMS\Application\SiteApplication::getMenu() should not be called statically in /home/berryinf/public_html/templates/gk_magazine/lib/framework/helper.layout.php on line 152

Deprecated: Non-static method Joomla\CMS\Application\CMSApplication::getMenu() should not be called statically in /home/berryinf/public_html/libraries/src/Application/SiteApplication.php on line 275

getUserMedia: stream video to your BB10 WebWorks App

If you ever wanted to stream into your BlackBerry 10 WebWorks app, it's pretty simple to do. This tutorial will include a brief example showing how to do it (and include all the necessary code).

1. Prepare all the basic elements for your app; the config.xml, any custom scripts and styling, and get everything set up.

2. Add the needed features and elements to your config.xml:

<rim:permissions>
<rim:permit>use_camera</rim:permit>
</rim:permissions>

I also recommend you use the following to lock the orientation: 

<feature id="blackberry.app">
<param name="orientation" value="portrait" />
</feature>

3. Create the following video and canvas elements on the page you want to stream video to:

<canvas id="canvas"></canvas>
<video id="video" style="display: none;" autoplay></video>

You'll probably want to include the height/width of your canvas in that element.

4. Add the code!If you're using bbUI, you can add it to the onDomReady event. If you're not, the easiest way to use it is to use a DOMContentLoaded event listener: document.addEventListener('DOMContentLoaded', function() {})

var video = document.getElementById("video");
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext('2d')
navigator.webkitGetUserMedia({video: true}, function(stream) {
     video.src = window.URL.createObjectURL(stream);
     setInterval(function () {ctx.drawImage(video, 0, 0, 300, 500);}, 20);
});

That's it! 

And if you're on your BlackBerry 10 device, or using Google Chrome, here's the above code in action:

Click here to see the code in action

Shane Cridlebaugh

Co-founder and legal nay-sayer of OSBB. Owner of SCrApps Application Development, WebWorks aficionado, Open Source contributor. SCrid2000 on most blogs. I build awesome BlackBerry apps when I'm not doing legal work or spending time with my wife and two boys.


Follow me on Twitter - @GShaneC

Check out my apps in BlackBerry World

Website: SCrApps.org

Leave your comments

Post comment as a guest

0

People in this conversation

Load Previous Comments
  • Guest (Tony L. Hall)

    BlackBerry 10 device is now getting great responses with the new features update, thank you so much for sharing this post. Top essay writing service is the one which I prefer for my academic writings.

    Like 0 Short URL:
  • Guest (jhon)

    I just would like to say you have shared very quality stuff in your content. This was quite new information for me. Thanks for sharing this with me.. small packaging boxes

    Like 0 Short URL:
  • Guest (alextyler)

    Very useful website it is. I read the post here all are very interesting and informative. The information you share in this become very helpful. I must share this with others and also visit this website again to get more interesting blogs. Keep sharing.
    long lasting tarpaulin sheet

    Like 0 Short URL:
  • Guest (Henry)

    Inserting and valuable stuff you have shared with us i would like to appreciate you for such type of authentic and beneficial stuff. Keep posting valuable and authentic articles in future.
    rubber flooring

    Like 0 Short URL:
  • Guest (ana)

    Much appreciated.incredible content so comprehensive.:)
    karachi stock exchange market watch

    Like 0 Short URL:
  • Guest (Mike)

    This is a nice and marvelous website with lots of unique features. I like such websites that are regularly updated on daily basis.
    Heavyduty trapulins at best price in UK

    Like 0 Short URL:
  • Guest (Pollock)

    I am very glad to read the post,it is very well written.You have done hard work in writing this post and i impressed your work. Thanks a lot
    rubber roofing services

    Like 0 Short URL:
  • Guest (Bramy)

    This is my first visit to this website and I have read many posts from here. These all are very informative for me and you have made a great effort for this. I will must visit here again to read more posts.
    garage shelving uk

    Like 0 Short URL:
  • Guest (dsmy)

    Really great and interesting post. I love it a lot and impressed your working style. You have done very well job. Thanks and keep it up
    Bubble Circular Tags

    Like 0 Short URL:
  • Guest (nimy)

    Excellent information on your blog, thank you for taking the time to share with us. Amazing insight you have on this, it's nice to find a website that details so much information
    invisible braces for adults

    Like 0 Short URL:
Subscribe to the official OSBB BBM Channel!

osbbchannelQR

C00013E89

Back to top