Mike Bevz's Blog http://mikebevz.com Most recent posts at Mike Bevz's Blog posterous.com Wed, 25 Apr 2012 05:40:00 -0700 Blackberry: Audio tag and 302 redirect are not friends http://mikebevz.com/blackberry-audio-tag-and-302-redirect-are-not http://mikebevz.com/blackberry-audio-tag-and-302-redirect-are-not

Apparantly, the audio tag on Blackberry 7.0 doesn't handle 302 redirect when streaming. For each track Soundcloud returns a temporary URL through 302 redirect, and while it works fine in the web browser on the device, when I packed it as an app it didn't want to load the stream. Solution for this was to make a proxy, that resolved a track stream_url to a remporary URL. It works now.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1623925/mike.jpg http://posterous.com/users/hckyglWJZrBJU Michael Bevz mikebevz Michael Bevz
Mon, 23 Apr 2012 13:21:00 -0700 Cake tasks for Webworks http://mikebevz.com/cake-tasks-for-webworks http://mikebevz.com/cake-tasks-for-webworks

I have recently started working with Webworks and as part of build automation I had to write a couple of tasks for Cake to build and deploy my app to Blackberry. They still requires (a lot)  some polishing, but it's already pretty cool time savers (taking into account that Blackberry is restarted after each deploy ~ 1 min). 

I use a great package called Hem (https://github.com/maccman/hem), that is a bundler for node.js. Amazing thing.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
path = require "path"
fs = require 'fs'
{exec} = require 'child_process'

SDKPath = "/Developer/WWSDK-2.3.1.5"
buildPath = "./build"
mainJsPath = "./public/application.js"
mainCssPath = "./public/application.css"
publicPath = "./public"
archiveName = "ts"
zipFilename = "#{archiveName}.zip"
appArchivePath = "#{buildPath}/#{zipFilename}"

devicePass= "password_to_your_device"
codPath = "#{buildPath}/StandardInstall/#{archiveName}.cod"
javaloaderPath = "#{SDKPath}/bin/javaloader"


task 'clean', 'Clean temporary files', ->
  console.log 'Cleaning up...'
  exec "rm -Rf #{buildPath}", (err, stdout, stderr) ->
    throw err if err
    console.log stdout + stderr
    console.log "Deleted #{buildPath}"
    return
  
  exec 'mkdir build', (err, stdout, stderr) ->
      throw err if err
      console.log stdout + stderr
      console.log "Created build dir"
  
  #TODO check for both files
  exec "rm #{mainJsPath} #{mainCssPath}", (err, stdout, stderr) ->
    throw err if err
    console.log stdout + stderr
    console.log "Clean in public"
  

task 'archive', 'Archive application', ->
  console.log 'Building with Hem...'
  
  exec 'hem build', (err, stdout, stderr) ->
    throw err if err
    console.log stdout + stderr
    console.log "Archiving #{publicPath} with ZIP to #{appArchivePath}"
    exec "cd #{publicPath}; zip -1 -r ../#{appArchivePath} .", (err, stdout, stderr) ->
      throw err if err
      console.log stdout + stderr
      console.log "Archived application to #{appArchivePath}"
               
task 'compile', "Compile blackberry app", ->
  console.log "Compiling Blackberry App"
  command = "#{SDKPath}/bbwp #{appArchivePath} -g #{devicePass} -o #{buildPath}"
  console.log "Executing command #{command}"
  exec command, (err, stdout, stderr) ->
    throw err if err
    console.log stdout + stderr
    console.log "Application compiled to #{buildPath}"
    
task 'deploy', "Compile blackberry app", ->
  console.log "Deploying application to device"
  exec "#{javaloaderPath} -w#{devicePass} load #{codPath}", (err, stdout, stderr) ->
    throw err if err
    console.log stdout + stderr
    console.log "Application successfully deployed"
    
      

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1623925/mike.jpg http://posterous.com/users/hckyglWJZrBJU Michael Bevz mikebevz Michael Bevz
Sun, 13 Nov 2011 11:21:00 -0800 Using Spotify content providers on Android http://mikebevz.com/using-spotify-content-providers-on-android-22161 http://mikebevz.com/using-spotify-content-providers-on-android-22161

I was hacking my phone and suddenly found three content providers that Spotify exposes. I googled a bit to figure out if anyone tried to use those. And the answer was - no, no one actually tried. Also no info on developer.spotify.com. After some time I managed to make them work. See below results of my findings.

Prerequisites: you need to have Spotify application installed. I don't know if you need a premium account, but I have one.

Content providers:

 

  1. com.spotify.mobile.android.model.StarredTracksContentProvider - provides access to all starred tracks.
  2. com.spotify.mobile.android.ui.PlaylistSearchProvider - Allows you to search tracks by a keyword. I expected it to search playlists, but probably it's not the case.
  3. com.spotify.mobile.android.ui.SearchProvider - I couldn't figure out this one. 

 

Let's start with the first one.

There are four columns in the table:

  1. _id
  2. name
  3. description
  4. intent

Short example:

 

public void getStarredTracks(Activity activity) {

String providerUri = "content://com.spotify.mobile.android.model.StarredTracksContentProvider";

String[] projection = new String[] { "_id", "name", "description", "intent" };

Cursor cursor = activity.managedQuery(Uri.parse(providerUri), projection, null, null, null);

 

if (cursor != null && cursor.moveToFirst()) {

int id_col = cursor.getColumnIndex("_id");

    int name_col = cursor.getColumnIndex("name");

    int description = cursor.getColumnIndex("description");

    int intent = cursor.getColumnIndex("intent");

do {

Log.d("SP",  "Track ID: " + cursor.getString(id_col));

     Log.d("SP", "Track name: " + cursor.getString(name_col));

   Log.d("SP", "Track description: "+cursor.getString(description));

Log.d("SP", "Intent: "+ cursor.getString(intent));

  } while (cursor.moveToNext());

 }

}

 

The second one has the following columns:

  1. _id
  2. suggest_text_1
  3. suggest_text_2
  4. suggest_intent_data

The code would be more less the same. The URI will be of course different.

String uri = "com.spotify.mobile.android.ui.PlaylistSearchProvider/search_suggest_query";

or

 

String uri = "com.spotify.mobile.android.ui.PlaylistSearchProvider/search_suggest_query/{keyword}";

 

Where {keyword} is, of course a keyword you would like to search against.

 

I hope it may be useful for somebody, it wasn't for me. I wanted to figure out a way to get a list of Spotify playlists into my application.

 

 

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1623925/mike.jpg http://posterous.com/users/hckyglWJZrBJU Michael Bevz mikebevz Michael Bevz