Giter Club home page Giter Club logo

videoplayer's Introduction

VideoPlayer plugin for Phonegap

The video player allows you to display videos from your PhoneGap application.

This command fires an Intent to have your devices video player show the video.

Adding the Plugin to your project

Using this plugin requires Android PhoneGap.

  1. To install the plugin, move www/video to your project's www folder and include a reference to it in your html file after phonegap.js.

    <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
    <script type="text/javascript" charset="utf-8" src="video.js"></script>

  2. Create a directory within your project called "src/com/phonegap/plugins/video" and move VideoPlayer.java into it.

  3. In your res/xml/plugins.xml file add the following line:

    <plugin name="VideoPlayer" value="com.phonegap.plugins.video.VideoPlayer"/>

Using the plugin

The plugin creates the object window.plugins.videoPlayer. To use, call the play() method:

  /**
	* Display an intent to play the video.
    *
    * @param url           The url to play
    */
  play(url)

Sample use:

window.plugins.videoPlayer.play("http://path.to.my/video.mp4");
window.plugins.videoPlayer.play("file:///path/to/my/video.mp4");
window.plugins.videoPlayer.play("file:///android_asset/www/path/to/my/video.mp4");
window.plugins.videoPlayer.play("https://www.youtube.com/watch?v=en_sVVjWFKk");

Note: When playing video from the assets folder, the video is first copied to internal storage with MODE_WORLD_READABLE.

RELEASE NOTES

October 2, 2011

  • Initial release

BUGS AND CONTRIBUTIONS

LICENSE

PhoneGap is available under either the terms of the modified BSD license or the MIT License (2008). As a recipient of PhonegGap, you may choose which license to receive this code under (except as noted in per-module LICENSE files). Some modules may not be the copyright of Nitobi. These modules contain explicit declarations of copyright in both the LICENSE files in the directories in which they reside and in the code itself. No external contributions are allowed under licenses which are fundamentally incompatible with the MIT or BSD licenses that PhoneGap is distributed under.

The text of the MIT and BSD licenses is reproduced below.


The "New" BSD License

Copyright (c) 2005-2011, Nitobi Software Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of Phonegap/Nitobi nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


The MIT License

Copyright (c) <2011> <Nitobi Software Inc., et. al., >

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

videoplayer's People

Contributors

idangozlan avatar macdonst avatar ssherriff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

videoplayer's Issues

Can't play video

Hi everyone! I would really need some help with this plugin, because I can't make the videos play. When clicking the link, nothing happens. I use .mp4 videos on other server.

In logs, I get an error: Uncaught SyntaxError: Unexpected token } at file:///android_asset/www/index.html:3

The code is

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="format-detection" content="telephone-no">
    <meta name="viewport" content="user-scalable=no, initial-scale=1, minimum-scale=1, maximum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi">
    <title>Our Application</title>
    <link rel="stylesheet" href="css/themes/default/jquery.mobile-1.3.2.css">
    <link rel="stylesheet" href="css/main.css">
    <link rel="stylesheet" href="css/foundation.css">
    <script src="js/vendor/custom.modernizr.js"></script>
    <script src="js/jquery.js"></script>
    <script src="js/jquery.mobile-1.3.2.js"></script>
    <script src="cordova.js"></script>
    <script type="text/javascript" charset="utf-8" src="js/index.js"></script>
    <script type="text/javascript" charset="utf-8" src="js/video.js"></script>
    <script>

    $.getJSON("http://www.privesc.eu/home/ios?categories%3DToate",
        function(data){
          $.each(data, function(i,entry){
           if(entry.LiveStatus == 3) { 
            content = '<div class="row">';
            content += '<div class="large-12 columns">';
            content += '<h2>' + entry.Title + '</h2>';
            content += '</div>';
            content += '<div class="large-12 columns">';
            content += '<h3><a href="#" onclick="window.plugins.videoPlayer.play("' + entry.VideoStreamUrl + '")">Play HTTP</a><h3>';
            content += '</div>';
            content += '</div>';
        } else {
            content = '<div class="row">';
            content = '<h2>' + entry.Title + '</h2>';
            content += '<p>planificat</p>';
            content += '</div>';        
        };

            $(content).appendTo("#entrylist");
          });
        });

        $("#getdata-button").on('click', function() {});


        function init() {
            document.addEventListener("deviceready", onDeviceReady, false);
        }



        function onDeviceReady() {
            alert('It works!');
        }

        function playVideo(vidUrl) {
        window.plugins.videoPlayer.play(vidUrl);
        }
    </script>
</head>
<body onLoad="init()">
    <div data-role="page" id="main">
    <div data-role="header" class="logo">
        <img src="img/logo.png" />
    </div>
    <div data-role="content">
        <div id="entrylist" data-role="listview">

        </div>



    </div>

    <div data-role="footer" data-theme="c">
        <h2 class="offline">footer</h2>
    </div>

</div>
<div data-role="page" id="newnote">
    <div data-role="header" class="logo">
        <img src="img/logo.png" />
    </div>
    <div id="notedetailcontent" data-role="content">
    </div>
    <div data-role="footer" data-theme="c">

    </div>
</div>
</div>
</body>
</html>

Any ideas how to solve this?

Thanks in advance.

Does the plugin support video streaming?

Sorry for posting a question rather than an issue, but I was wondering if your plugin supports video streaming on Android with Phonegap and if so what format the stream needs to be in.

Thanks!

Dynamic video: check if online or offline

So I'm making an app that both works online and offline. When there's no connection, it should play the local file (let's just assume for a moment that the user has that file on his phone/tablet). When there is a connection, it should play the video on youtube. I gave it a go, but maybe you can give me some directions?

function showVideo() {
db.transaction(function (tx) {
tx.executeSql('SELECT * FROM ARTIST WHERE VIDEO="yes"', [], function (tx, results) {
var networkState = navigator.network.connection.type;
var len = results.rows.length, i;
for (i = 0; i < len; i++){
if (networkState == Connection.NONE){
window.plugins.videoPlayer.play("'+results.rows.item(i).video_off+'");
}
else{
window.plugins.videoPlayer.play("'+results.rows.item(i).video_on+'");
}
}
document.getElementById("video").innerHTML = home;

}, null);
});
}

Local videos no longer play after YouTube video is played.

Hi,

Having a strange issue using the plugin.

All my local videos play correctly and all my YouTube videos play correctly.

The problem appears to be, after a YouTube video is played none of the local videos contained in the app will load. This even happens if I don't use the plugin to load YouTube video and include them in an iFrame.

When the app resumes, the error in LogCat is:

"Uncaught TypeError: Cannot read property 'videoPlayer' of undefined"

Any help or advice would be greatly appreciated.

I can't play Video ;(

Hi,
i'm trying to use your plugin but i can't do it...i follow your readme steps...
-copied VideoPlayer.java in src.com.phonegap.plugins.video
-copied video.js in www folder

-added plugin in config.xml:

-added reference to my html head:

<script type="text/javascript" charset="utf-8" src="video.js"></script>

-called the plugin:
function parti() {
window.plugins.videoPlayer.play('https://www.youtube.com/watch?v=OARLx5oKBUw');
console.log('playing Video');
};

but nothings happen ;( What wrong? i have to set somethings else?!
Please Help me ;)

my LogCat
07-23 02:43:53.520: V/WebViewInputDispatcher(4521): blockWebkitDraw
07-23 02:43:53.520: V/WebViewInputDispatcher(4521): blockWebkitDraw lockedfalse
07-23 02:43:53.530: V/webview(4521): singleCursorHandlerTouchEvent -getEditableSupport FASLE
07-23 02:43:53.825: D/webview(4521): blockWebkitViewMessage= false
07-23 02:43:53.975: I/Web Console(4521): playing Video:5111

Video won't play

In the console I get this.

06-08 19:46:02.882: I/Web Console(10207): video played at file:///android_asset/www/cordova-2.6.0.js:5310

and the video does not play.

The code I have actuating it is

$scope.androidPlayVideo = function (videoUrl){
console.log('playing Video');
window.plugins.videoPlayer.play(videoUrl);
console.log('video played');
}

I can't play rtsp

Hi.. i can't play rtsp live streaming, but if local or youtube works fine.... please help me.... thanks

binding video events

Hi Simon,

How do you bind to events from the media player? If I wanted to find out when the video was finished or started or in the middle of playback, how would I capture those events?

In the logcat i can see that those events are there, but I'm having some trouble intercepting them.

Thanks

Jake

Error Message If Youtube App is not Installed (Ux improvement)

Hello,
i think it would be nice if the plugin had a javascript alert feature that notified the user that the Youtube app is not installed on their device and that they would be redirected to the playstore to download it. This feature would make the app/plugin more user friendly.

As opposed to just automatically redirecting them to the playstore to download the Youtube app.

Thanks for making the plugin tho :-)

Can't build app

Hello!
I added VideoPlayer to Hello World PhoneGap application.

But while building I get next problems:

-dex:
[dex] input: D:\Build\Android\PhoneGap\video\platforms\android\bin\classes
[dex] input: D:\Build\Android\PhoneGap\video\platforms\android\libs\cordova-3.0.0.jar
[dex] Pre-Dexing D:\Build\Android\PhoneGap\video\platforms\android\libs\cordova-3.0.0.jar -> cordova-3.0.0-dcb01b803346297fc6233e00d113c728.jar
[dex] Converting compiled files and external libraries into D:\Build\Android\PhoneGap\video\platforms\android\bin\classes.dex...
[dx]
[dx] UNEXPECTED TOP-LEVEL EXCEPTION:
[dx] com.android.dx.util.DexException: Multiple dex files define Lcom/phonegap/hello_world/HelloWorld;
[dx] at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:592)
[dx] at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:550)
[dx] at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:531)
Failed to find apk, make sure you project is built and there is an
apk in \bin. To build your project use '\cordova\build'

Please advise solution to that problem?

Android Webview

Can this plugin play local videos as inline Android Webview app?
If yes,how do I code the tags?

No connection: local file, connection: youtube video

Hi Simon,

before the last SDK update the videoplayer worked perfectly for me. I implemented a statement that when the user is offline, the local videofile gets played, but when he's online he gets redirected to Youtube. Since I updated the SDK via Eclipse's Android SDK manager the statement isn't working anymore.

Here's my script:

function clickKunstenaar0(){
    var networkState = navigator.connection.type;

    if (networkState == Connection.WIFI || networkState == Connection.CELL_3G || networkState == Connection.CELL_4G){
        window.plugins.videoPlayer.play("http://youtu.be/VYSU-Vae_k4");
    }
    else{
        window.plugins.videoPlayer.play("file:///sdcard/download/ilshuygens.mp4");
    };
    }

and the corresponding HTML:

a href="#" onclick="clickKunstenaar0();" img src="images/video.png"

When you push the button at the moment, you always get the local file, no matter if you're on or offline. If I change the statement to indicate when the user is offline and go to the else statement when he's online, the Youtube video gets played if there's a connection, but nothing happens when there's no connection.

The logcat isn't indicating anything special either so I have absolutely no idea what's wrong.

canot play video

when i click on video, video not playing and i am getting alert message as cannot play video.
The video not copied in to internal storage.

canot play video

when i click on video button, video not playing and i am getting alert message as cannot play video.
The video not copied in to internal storage.

Video only plays once

Hi

I have your plugin working, but i have an issue replaying files the first time i play a video it plays fine but the second time i get nothing.

My app is simple it loads a list of templates from a db and plays them one by one for a set duration after this duration the div is cleared and the next layout is loaded.

m3u8 need long time to bufffer

i have an livestream formated m3u8.
andriod browers work well, but cordova can't work.
so i install this pluin.
but it's buffing very long time, 1min. when buffed, and it's working 10s, and then buffing 1min.

my device is very power, android 4.4 .

thanks.

MODE_WORLD_READABLE Deprecated

Thanks for working on this plugin, but I'm having trouble getting it to work. This is my first time fiddling with phonegap plugins so I could be spitting nonsense.

Anyway I get a "Error calling method on NPObject" on line 855 of cordova-2.5.0.js which is in the function androidExec().

Someone on the phonegap google groups said that NPObject errors can be Java errors that bubble up to the javascript that then doesn't know what to do with. So I looked in the VideoPlayer.java and Eclipse gave me a warning on line 112:

FileOutputStream out = this.cordova.getActivity().openFileOutput(fileTo, Context.MODE_WORLD_READABLE);

Googling that is where I found that the constant, MODE_WORLD_READABLE was deprecated in API Level 17.

Since videos are initially saved using this constant, could that be why I can't get the player running in my environment? Anything about that make sense or am I just complicating a simple issue?

Can’t play this video error?

Hi,
I’m trying to play a simple .MP4 via the plugin, but get an error reading “Can’t play this video” as soon as the video play is invoked. I can play the video file in the Andorid standalone video player, and I can call a Youtube video via your plugin. Please advise,

Page Code

<title> Example</title>
<script type="text/javascript" charset="utf-8" src="cordova-2.5.0.js"></script>
<script type="text/javascript" charset="utf-8" src="video.js"></script>

    <script type="text/javascript">


    //app.initialize();

    function init()
    {
        document.addEventListener("deviceready", console.log('ready'), true);
    }

    function playVideo(vidUrl) {
        //alert("Starting Vid Script");
        window.plugins.videoPlayer.play(vidUrl);
    }
</script>
Play Stream
Play File
Play File from web
Play File from SD

Error Videoplayer.java

Hi,

I tried implementing this plugin like you explained in your readme file, however I'm getting an error in the videoplayer.java file.

On this line: FileOutputStream out = this.cordova.getActivity().openFileOutput(fileTo, Context.MODE_WORLD_READABLE);

it says 'Using MODE_WORLD_READABLE when creating files can be risky, review carefully'.

What can I do about it?

Play all video from sdcard

I'm using this plugin that works fine for online or single url from asset file.
I need to play all the local videos from the sdcard. Is there any way so that i can play all videos?

Thanks!

videoplayer undefined

Hi macdonst, i will be really gratefull if you could post an full project example for cordova 2.2.0, im trying to make it work but unsuccessfully. Please help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.