Ads

Wednesday, August 7, 2013

Android YouTube Player

Android module that plays videos from YouTube.

This module create an Android activity that allows developers to play videos that are hosted on YouTube. This module is based on Android YouTube player library.

The original code was created by KeyesLabs (www.keyeslabs.com) as part of the Screebl project. The developers wanted the ability to play YouTube-hosted help videos, and wanted those videos to be able to play on any device, even those that didn't have the stock YouTube player app.

Android YouTube Player
NOTE: If module unable to get the RTSP url from YouTube server, then video cannot be played.

Features:
  • Higher Bandwidth Video
    This module plays higher bandwidth video from YouTube server as new Activity.
  • Auto Play
    Without user interaction, video will will play automatically in landscape mode once it is loaded from YouTube server.
  • Video Player Controls
    YouTube video player comes with default controls like play, pause, SeekForward, SeekBackward.
  • Play by Video Id and Playlist Id
    playVideo method takes video id as input parameter and plays video automatcally.
    playPlayListVideo
    method takes playlist id as input parameter then it will play the latest video added to a YouTube playlist.
Usage:
var win = Ti.UI.createWindow({
 backgroundColor : "#fff",
 layout : "vertical"
});

var youtubePlayer = require('titutorial.youtubeplayer');
Ti.API.info("module is => " + youtubePlayer);

/*
 * Play video by videoId
 */
var playVideo = Ti.UI.createButton({
 title : 'Play video',
 height : '40dp',
 width : Ti.UI.SIZE,
 top : '100dp'
});
win.add(playVideo);

playVideo.addEventListener('click', function() {
 youtubePlayer.playVideo("FjMs_imWkFM");
});

/*
 * Play video by playListId
 */
var playPlayListVideo = Ti.UI.createButton({
 title : 'Play playlist video',
 height : '40dp',
 width : Ti.UI.SIZE,
 top : '100dp'
});

playPlayListVideo.addEventListener('click', function() {
 youtubePlayer.playPlayListVideo("PLB03EA9545DD188C3");
});

win.add(playPlayListVideo);

win.open();
Download:
Module: https://marketplace.appcelerator.com/apps/6223?942520925
Source code: https://github.com/railskarthi/YoutubePlayer-Android

Screenshot:
Android YouTube Player
Android YouTube Player
 

7 comments:

  1. Hello, thanks for this module, but i have a question.

    There is a way to handle if the video is paused, is resumed or completed? Some addEventListener?

    Thank you very much!

    ReplyDelete
  2. Guille, Since Android YouTube player library (http://code.google.com/p/android-youtube-player/wiki/OpenYouTubePlayerActiviyInstructions) doesn't have the EventListener for paused, is resumed or completed. So I cannot add these things to the current module.

    But If I develop a new module using some other youtube player library. I can add those EventListeners.

    ReplyDelete
  3. Ok, thanks for answering.
    Do you know what can I do to handle video events playing a youtube video?
    The only thing I can do I think is get the .mp4 url of each video and use Ti.Media.VideoPlayer element.


    Thanks anyway!

    ReplyDelete
  4. Hi Karthi I have Used this awesome player this is working fine.There is a small issue in Galaxy S4 specifically that video player is opened on the full screen video is player just like a thumbnail in the center of player.Please guide me what can be the issue.I have attached screenshot you can have idea from it.Thanks for your time.

    ReplyDelete
  5. There is an issue.https://www.dropbox.com/s/kpo3gw9ym4u995d/Screenshot_2014-03-24-20-25-54.pngcheck this link. Please guild me if anyone has idea to resolve this problem this is specifically on Samsung Galaxy S4.Thanks.

    ReplyDelete
  6. @fizza , Android YouTube player library(http://code.google.com/p/android-youtube-player/) itself having issue with Galaxy S4.

    So I cannot able to fix it. Sorry.

    ReplyDelete
  7. hi

    on screen lock video player is not pausing , any idea for this

    regards
    kavya

    ReplyDelete