Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Android Intents - Youtube search

I want to use an Android Intent to open the native youtube app in order to do the following (using a different intent)
The following works

var intent = Ti.Android.createIntent({
   action: Ti.Android.ACTION_VIEW,
   data: "http://m.youtube.com/results?q=mysearch&uploaded=w"
});
Ti.Android.currentActivity.startActivity(intent);

The following works but I couldn't figure out how to set a time filter

var intent = Ti.Android.createIntent({
   action: Ti.Android.ACTION_SEARCH,
   packageName: "com.google.android.youtube"
});
intent.putExtra("query", "mysearch");
//the following line is the problem, 
//I've also tried intent.putExtra("time", "this_week") without success
intent.putExtra("uploaded", "w");
Ti.Android.currentActivity.startActivity(intent);

I don't even know if this is possible.

Thanks in advance

— asked January 10th 2011 by Aitor Lapena
  • 1.5.1
  • action_search
  • android
  • intents
  • mobile
  • sdk
  • youtube
2 Comments
  • Hi! Did you get this working? Thank you!

    — commented June 9th 2011 by Daniel Maceira
  • This may be too late, but maybe it will be helpful to others who are searching for this. This is my code for playing youtube videos on the youtube player app using intents -

    openYouTubeVideo = function(appFile){
        var tmpFile = undefined,
            newPath = undefined;
            try {
                 if(Ti.Android.currentActivity == null){
                     // alert("Current activity is null");
    
                 }
                var intent = Ti.Android.createIntent({
                    action: Ti.Android.ACTION_VIEW,                
                    data: 'vnd.youtube:' + appFile
                       });
                 Ti.Android.currentActivity.startActivity(intent);
                logVA("After currentActivity.startActivity(intent)");
            }
            catch (err) {
                logVA("&&&&&^^^%%$##@# Error on  Viewing : " + err);
                var alertDialog = Titanium.UI.createAlertDialog({
                    title: 'No Youtube player',
                    message: 'We tried to open a Youtube but failed. Do you want to search the marketplace for a Youtube viewer?',
                    buttonNames: ['Yes','No'],
                    cancel: 1
                });
                alertDialog.show();
                alertDialog.addEventListener('click', function(evt) {
                    if (evt.index == 0) {
                        Ti.Platform.openURL('http://search?q=pdf');
                    }
                });
            }
    
    }
    

    Hope this helps!

    This works great. But now, I am looking to see how I can get the Youtube app to play the video in full screen mode by default.

    Thanks,
    Sri

    — commented November 19th 2011 by Sridevi Kolluri

2 Answers

  • Hi Daniel, I haven't tried the same with the last version 1.6.2. This was 5 months ago, I guess it was version 1.5.
    If you find a solution let me know! Thanks!

    — answered June 10th 2011 by Aitor Lapena
    permalink
    0 Comments
  • did you ever get this working ?

    — answered July 26th 2011 by Brian Dittmer
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.