-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
TheFinestArtist
committed
Feb 15, 2015
1 parent
9e6e857
commit 1417659
Showing
21 changed files
with
140 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 TheFinestArtist | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Moving Button | ||
|
||
Simply pass a url to play youtube video on new activity. It supports screen orientation, media volume control and etc. | ||
|
||
```xml | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<activity | ||
android:name="com.thefinestartist.ytpa.YouTubePlayerActivity" | ||
android:configChanges="keyboardHidden|orientation|screenSize" | ||
android:screenOrientation="sensor" | ||
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" > | ||
</activity> | ||
``` | ||
|
||
## YoutubeUrlParser | ||
|
||
https://androidsnippets.wordpress.com/2012/10/11/how-to-get-extract-video-id-from-an-youtube-url-in-android-java/ | ||
|
||
|
||
## License | ||
|
||
``` | ||
The MIT License (MIT) | ||
Copyright (c) 2015 TheFinestArtist | ||
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. | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
library/src/main/java/com/thefinestartist/ytpa/utils/YoutubeUrlParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.thefinestartist.ytpa.utils; | ||
|
||
import android.net.Uri; | ||
|
||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
/** | ||
* Created by TheFinestArtist on 2/15/15. | ||
*/ | ||
public class YoutubeUrlParser { | ||
|
||
// ^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/ | ||
final static String reg = "^.*((youtu.be\\/)|(v\\/)|(\\/u\\/w\\/)|(embed\\/)|(watch\\?))\\??v?=?([^#\\&\\?]*).*"; | ||
|
||
public static String parseVideoId(String url) { | ||
String videoDd = null; | ||
if (url != null && url.trim().length() > 0 && url.startsWith("http")) { | ||
Pattern pattern = Pattern.compile(reg, Pattern.CASE_INSENSITIVE); | ||
Matcher matcher = pattern.matcher(url); | ||
|
||
// Regular reg some how doesn't work with id with "v" at prefix | ||
if (matcher.matches()) { | ||
String groupIndex = matcher.group(7); | ||
if (groupIndex != null && groupIndex.length() == 11) | ||
videoDd = groupIndex; | ||
else if (groupIndex != null && groupIndex.length() == 10) | ||
videoDd = "v" + groupIndex; | ||
} | ||
} | ||
return videoDd; | ||
} | ||
|
||
public static String getVideoId(String url) { | ||
if (url == null) | ||
return null; | ||
|
||
Uri uri = Uri.parse(url); | ||
String videoId = uri.getQueryParameter("v"); | ||
|
||
if (videoId == null) | ||
videoId = parseVideoId(url); | ||
|
||
return videoId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" | ||
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" | ||
android:paddingRight="@dimen/activity_horizontal_margin" | ||
android:paddingTop="@dimen/activity_vertical_margin" | ||
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"> | ||
|
||
<TextView android:text="@string/hello_world" android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" /> | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".MainActivity"> | ||
|
||
</RelativeLayout> |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="primary">#F44336</color> | ||
<color name="primary_dark">#D32F2F</color> | ||
<color name="primary_light">#FFCDD2</color> | ||
<color name="accent">#9E9E9E</color> | ||
<color name="primary_text">#212121</color> | ||
<color name="secondary_text">#727272</color> | ||
<color name="icons">#FFFFFF</color> | ||
<color name="divider">#B6B6B6</color> | ||
</resources> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
<resources> | ||
<string name="app_name">sample</string> | ||
|
||
<string name="hello_world">Hello world!</string> | ||
<string name="action_settings">Settings</string> | ||
<string name="app_name">Youtube Player</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
<resources> | ||
|
||
<!-- Base application theme. --> | ||
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar"> | ||
<!-- Customize your theme here. --> | ||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | ||
<item name="android:windowBackground">@android:color/white</item> | ||
<item name="colorPrimary">@color/primary</item> | ||
<item name="colorPrimaryDark">@color/primary_dark</item> | ||
<item name="colorAccent">@color/accent</item> | ||
<item name="android:textColorPrimary">@color/primary_text</item> | ||
<item name="android:textColorSecondary">@color/secondary_text</item> | ||
<item name="windowActionBar">false</item> | ||
</style> | ||
|
||
</resources> |