-
-
Notifications
You must be signed in to change notification settings - Fork 257
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
1 parent
8856d2f
commit ccba687
Showing
11 changed files
with
147 additions
and
50 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
34 changes: 34 additions & 0 deletions
34
News-Android-App/src/extra/java/de/luhmer/owncloudnewsreader/YoutubePlayerManager.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,34 @@ | ||
package de.luhmer.owncloudnewsreader; | ||
|
||
import android.app.Activity; | ||
import android.app.FragmentTransaction; | ||
|
||
import com.google.android.youtube.player.YouTubeInitializationResult; | ||
import com.google.android.youtube.player.YouTubePlayer; | ||
import com.google.android.youtube.player.YouTubePlayerFragment; | ||
|
||
import org.greenrobot.eventbus.EventBus; | ||
|
||
import de.luhmer.owncloudnewsreader.events.podcast.RegisterYoutubeOutput; | ||
|
||
public class YoutubePlayerManager { | ||
|
||
public static void StartYoutubePlayer(final Activity activity, int YOUTUBE_CONTENT_VIEW_ID, final EventBus eventBus, final Runnable onInitSuccess) { | ||
YouTubePlayerFragment youTubePlayerFragment = YouTubePlayerFragment.newInstance(); | ||
FragmentTransaction ft = activity.getFragmentManager().beginTransaction(); | ||
ft.add(YOUTUBE_CONTENT_VIEW_ID, youTubePlayerFragment).commit(); | ||
youTubePlayerFragment.initialize("AIzaSyA2OHKWvF_hRVtPmLcwnO8yF6-iah2hjbk", new YouTubePlayer.OnInitializedListener() { | ||
@Override | ||
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean wasRestored) { | ||
eventBus.post(new RegisterYoutubeOutput(youTubePlayer, wasRestored)); | ||
onInitSuccess.run(); | ||
} | ||
|
||
@Override | ||
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) { | ||
youTubeInitializationResult.getErrorDialog(activity, 0).show(); | ||
//Toast.makeText(activity, "Error while playing youtube video! (InitializationFailure)", Toast.LENGTH_LONG).show(); | ||
} | ||
}); | ||
} | ||
} |
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
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
6 changes: 2 additions & 4 deletions
6
...-App/src/main/java/de/luhmer/owncloudnewsreader/events/podcast/RegisterYoutubeOutput.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 |
---|---|---|
@@ -1,15 +1,13 @@ | ||
package de.luhmer.owncloudnewsreader.events.podcast; | ||
|
||
import com.google.android.youtube.player.YouTubePlayer; | ||
|
||
public class RegisterYoutubeOutput { | ||
|
||
public RegisterYoutubeOutput(YouTubePlayer youTubePlayer, boolean wasRestored) { | ||
public RegisterYoutubeOutput(Object youTubePlayer, boolean wasRestored) { | ||
this.youTubePlayer = youTubePlayer; | ||
this.wasRestored = wasRestored; | ||
} | ||
|
||
public YouTubePlayer youTubePlayer; | ||
public Object youTubePlayer; // (Type: com.google.android.youtube.player.YouTubePlayer;) | ||
public boolean wasRestored; | ||
|
||
} |
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
11 changes: 11 additions & 0 deletions
11
News-Android-App/src/oss/java/de/luhmer/owncloudnewsreader/YoutubePlayerManager.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,11 @@ | ||
package de.luhmer.owncloudnewsreader; | ||
|
||
import android.app.Activity; | ||
import org.greenrobot.eventbus.EventBus; | ||
|
||
public class YoutubePlayerManager { | ||
|
||
public static void StartYoutubePlayer(final Activity activity, int YOUTUBE_CONTENT_VIEW_ID, final EventBus eventBus, final Runnable onInitSuccess) { | ||
// Dummy | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...pp/src/oss/java/de/luhmer/owncloudnewsreader/services/podcast/YoutubePlaybackService.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,47 @@ | ||
package de.luhmer.owncloudnewsreader.services.podcast; | ||
|
||
import android.content.Context; | ||
import android.util.Log; | ||
import android.widget.Toast; | ||
|
||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
import de.luhmer.owncloudnewsreader.model.MediaItem; | ||
|
||
/** | ||
* Created by david on 31.01.17. | ||
*/ | ||
|
||
public class YoutubePlaybackService extends PlaybackService { | ||
|
||
public YoutubePlaybackService(Context context, PodcastStatusListener podcastStatusListener, MediaItem mediaItem) { | ||
super(context, podcastStatusListener, mediaItem); | ||
setStatus(Status.FAILED); | ||
} | ||
|
||
@Override | ||
public void destroy() { } | ||
|
||
@Override | ||
public void play() { } | ||
|
||
@Override | ||
public void pause() { } | ||
|
||
public void seekTo(double percent) { } | ||
public int getCurrentDuration() { | ||
return 0; | ||
} | ||
|
||
public int getTotalDuration() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public VideoType getVideoType() { | ||
return VideoType.YouTube; | ||
} | ||
|
||
public void setYoutubePlayer(Object youTubePlayer, boolean wasRestored) { } | ||
} |