Monday, 3 August 2015

Play video from uncompressed zip fill (obb)

I've not posted anything to my blog in along time,
But getting this to work get so round up I want help anybody else that might run into it.

So you might have an Android app that required the playback of large local videos mp4s for example.

That might take your app size over 50mb which means that you have to package your larger assets up as apk expansion files.

So first off go read this..
http://developer.android.com/google/play/expansion-files.html


Then package your mp4s up as non compressed zip file. Im on windows and to do this I used 7 zip file manager.

then rename it to .obb file as described in the above documentation.

Once you have it on a device to test.

Create a class like this...
[code]
public class ZipFileContentProvider extends APEZProvider {

    @Override
    public String getAuthority() {
        return "com.adt.adtfordapp.ZipFileContentProvider";
    }
}
[/code]


and in your manifest add a provider under application (not in activitiy)
""""






Thursday, 20 September 2012

as3 empty a movieclip

Say you have a movieclip that has either dynamically added children or objects you added in there before calling it to the stage and at some point you need to just empty it... start again....

Well I was  a little puzzled as to how to do that. However I did find this 3 liner and works a flipping treat!

for (var i:int = cliptoclear.numChildren - 1; i >= 0; i--) {

       cliptoclear .removeChildAt(i);
}


.

Wednesday, 29 August 2012

Resize html5 canvas width/height element to its content

I   needed method to resize the width of my html5 canvas so that it was the total width of its content.

Im looking for a similar method to the one below. Unfortunately you can't change the width of a canvas element half way through your code with out redrawing it.... pants.

I think theirs away to save the content of the canvas to an image before you re-size the width.
After which you simply redraw the content after re-size.
...I couldnt get it to work so my codes a little bit more drawn out.




var canvas;
var context;
var width;
var height;

function domLoaded(e){
canvas = document.getElementById("scroller");
context = canvas.getContext("2d");
width = canvas.getAttribute('width');
height = canvas.getAttribute('height');
var imageObj = new Image();
canvas.style.backgroundColor="red";

imageObj.onload = function() {
context.drawImage(imageObj, 0, 0);
var txt = "Doesnt matter how much text you put here the canvas will resize.";
context.font = "15pt Calibri";
context.fillText(txt,imageObj.width, 15);
var totalWidth = context.measureText(txt).width+imageObj.width;
canvas.width = totalWidth;

width = canvas.getAttribute('width');
context.drawImage(imageObj, 0, 0);
context.font = "15pt Calibri";
context.fillText(txt,imageObj.width, 15);
};
imageObj.src = "http://www.html5canvastutorials.com/demos/assets/darth-vader.jpg";



}
document.addEventListener("DOMContentLoaded", domLoaded);

Tuesday, 28 August 2012

draw html5 canvas element to a master canvas element

I wanted a method where by I could group elements together and then draw that group to my main html5 canvas element.
So from a flash point of view this would be similar to creating an empty moving clip and then using addchild add content to that movieclip.
Then add the movieclip to the stage.


So I found this post....
http://kaioa.com/node/103

I kind of got it... But I'm a little new to javascript and to me it seemed a little bit complicated to having methods sent into other methods.

So I changed it a little for somthing that sits more comfortably in my brain sells!

My code looks like this and was just what I was after...


var canvas;var context;var width;var height;


function domLoaded(e){
canvas = document.getElementById("scroller");
context = canvas.getContext("2d");
width = canvas.getAttribute('width');
height = canvas.getAttribute('height');

var renderToCanvas = function (width, height) {
var buffer = document.createElement('canvas');
var canvasCradle = buffer.getContext("2d");
buffer.width = width;
buffer.height = height;
  canvasCradle.font = "15pt Calibri";
canvasCradle.fillText("Morning all!", 25, 20);
return buffer;
};

var cached = renderToCanvas(150, 25);
context.drawImage(cached, 0, 0);

}
document.addEventListener("DOMContentLoaded", domLoaded);



So on Dom load I GET my canvas element that has an id called scroller from my html markup.

I get its width/hight/context ect and set them to vars.

Now Im ready to create a new canvas element to be drawn to "canvas"

Ive created cached which is equal to the method renderToCanvas
This then creates a new canvas element
I can treat that like any other canvas elements... add what I want to it. I return that canvas element

Cached is now that element I created on the fly and I can now use drawImage on master canvas to draw it to screen.


Sunday, 5 August 2012

new app simple lists

I released my new app to the android market on Saturday afternoon. "simple lists"
Does what it says on the tin. Its a simple way to make lists. 
You start by naming a list and giving a description and then your free to add list items to it.
Once you have added your list items you can then swipe them left/right to mark an item as done or not done.
Both lists and items can be deleted  by holding your finger down on a item.
Theres also an info button that allows you to see more information about the list or item.

Thats pretty much it really!
Its taken me three months of weekends and evenings to put together.
Ive developed it using the corona sdk. Ive learnt alot, setting up sqllite databases and touch events within a scroll widget. 

But thats my last app, Ive done two now and not received a penny. 

I will hopefully be porting both googly face...


and my new app "simple lists"...


...to the apple market soon. I dont expect them to excel, but its been a good experience working with lua and corona. I think its put some decent feathers in my hat as well.


 

Tuesday, 31 July 2012

3 Day mountain bike trip, Lakes and Scotland

Me and my friend Jamie set off from York on Friday morning for the Lake District and then on to Scotland.

photos from out 3 day trip are here...
Flickr album of Lakes and Scotland mountain biking

We got our Bikes into the back of Jamies Pickup truck. I had my specialized pro pitch 2011. Jamie had his Specialized XC.
We were going for an old favourite, Whinlatter...
http://www.forestry.gov.uk/alturatrail

Whinlatter is like a RollerCoaster but one that lasts a bit longer! Climb for a while, downhill, climb for a while and one final downhill. You could easily do two runs of this trail in a day.
It sounds basic but its great. The climbs are fine and the downhill sections are great. Lovely berms, switch backs and jumps.
Heres the stats on that ride...
http://www.endomondo.com/workouts/75609808



After that we chucked the bikes into the pickup, we had a quick pint in a nice local pub and booted it up to Innerleithen, Scotland.
We were staying at a local camp site in tents...
http://www.tweedsidecaravanparkinnerleithen.co.uk/

Nice enough but I had managed to forget my sleeping bag and pillow. ... Winning.
We were meeting a friend in Innerleithen that was stopping in a Cottage with a group of his mates that had also come up from York. We all went out for a meal that evening at a local Italian. I got smashed in the hope it would knock me out, so that I might sleep even without a sleeping bag. ... Didnt work. Didnt sleep well at all.

Any how after a hearty breakfast it was time for the first trail of the day at Innerleithen. This has some killer black routes. we Got there at 10am and already I must of counted 20/30 top of the range downhill bikes... Beasts... But no good for the climb we were about to do on the red route. Climbed for over an hour. Big big climb. We climbed from 620ft to 2025ft.

But in return for out hard work we got some of the most epic downhil trails Ive done. Not sure which was more excited, me or the bike! It just felt really at home on that trail, safe and absolutely able to smash it. Some lovely jumps that you had time to get ready for. Towards the bottom we got some good flatter trail with fast switch backs.
At the end for the last mile you join the down hill black. Probably the most testing part of the ride for me and the bike. ... one word Epic! I had downhillers coming down at all angles in full face helmets and neck brasses. But I think me and the pro pitch held our own. I was hanging off the back of the bike with my seat right down while my bike threw me into corners and jumps with no problem. Great great fun.

The stats for Innerleithen...
http://www.endomondo.com/workouts/75609808


The Innerleithen Run was just for starters! A couple of the lads bikes needed a bit of maintance one bike had snapped a chain the other smashed a gear shifter on a fall. These guys sorted any issues out in double time for us...
http://www.alpinebikes.com/


We then loaded all the bikes into the van and Jamies pickup truck and rocked up to Glentress, 10 minutes drive for Innerleithen. Glentress had everything you would need blue,red, black runs and a massive jump park.

We started off with a bite to eat in the cafe and then headed up another long uphill red route. After maybe 45minutes we got to the top. I was really starting to feel low on energy now. Food nor energy bars would make feel any better. I was reaching my limit for the day.
After a 5 minute break we set off down into the first part of the trail "spooky wood". ... amazing. Again I seemed to feel more at one with bike with the seat post right down and my ass hanging off the back and letting the bike tear into corners and shifting my weight with it. It was awesome, the reason I had bought this bike was for this kind of stuff. Switch backs, berms, table tops, humps, jumps. It had it all.
Towards the end I was really starting to suffer. I was desperate to keep my energy up so I could push the bike where I wanted it to go but my arms were starting to give up. I had got to the point of just holding on!
By the time we got to the end my head was saying lets go again... my body was saying lets sleep for a week! ...

The stats...
http://www.endomondo.com/workouts/75927685


That evening I opted to stop in the cottage, a spare bunk bed was going so I had that.
For food we took a taxi over to peebles... Which just so happened to be where my mum and dad had there honey moon 30 something years ago.
Burger,beers,Taxi home, In-betweeners the movie DVD then BED

Next morning we had hoped to give the black run a going over at Glentress, but the lads that had done it in the past said it would be a bad idea... Apparently the climbs are a bit intense! Instead we opted for a raz round the jump park and then back to the top using short cuts up fire roads to spooky wood and down again.
This time we went for some of the blue run. The blue run is great! It is a must. smooth switchbacks with jumps and berms.
This happened to be the only place on the entire trip where I nearly lost it. Took a table top jump with my weight over the front... Just managed to get it back over the rear wheel before landing.
I am crap at jumps though... must manage my weight better, and trust in my bike!

And that was it done! back to york in 3/4 hours.
http://www.endomondo.com/workouts/75927685



Once again these are the photos from our three days...
Flickr album of Lakes and Scotland mountain biking

Amazing weekend!


Saturday, 21 July 2012

Love #listeningto Virginia Plain by Roxy Music out loud on my Sonos