Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
appinventor-sources
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
appinventor-sources
Commits
01f7807f
Commit
01f7807f
authored
Apr 13, 2020
by
Evan W. Patton
Committed by
Jeffrey Schiller
Apr 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing READ_EXTERNAL_STORAGE permission for Player and VideoPlayer
Change-Id: Icebd59c7b7a7e112f42514a3531cb78ef1537c01
parent
9048ac1d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
24 deletions
+56
-24
appinventor/components/src/com/google/appinventor/components/runtime/Player.java
...src/com/google/appinventor/components/runtime/Player.java
+25
-10
appinventor/components/src/com/google/appinventor/components/runtime/VideoPlayer.java
...om/google/appinventor/components/runtime/VideoPlayer.java
+31
-14
No files found.
appinventor/components/src/com/google/appinventor/components/runtime/Player.java
View file @
01f7807f
...
...
@@ -6,6 +6,14 @@
package
com.google.appinventor.components.runtime
;
import
static
android
.
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.media.AudioManager
;
import
android.media.MediaPlayer
;
import
android.media.MediaPlayer.OnCompletionListener
;
import
android.os.Vibrator
;
import
com.google.appinventor.components.annotations.DesignerComponent
;
import
com.google.appinventor.components.annotations.DesignerProperty
;
import
com.google.appinventor.components.annotations.PropertyCategory
;
...
...
@@ -17,20 +25,11 @@ import com.google.appinventor.components.annotations.UsesPermissions;
import
com.google.appinventor.components.common.ComponentCategory
;
import
com.google.appinventor.components.common.PropertyTypeConstants
;
import
com.google.appinventor.components.common.YaVersion
;
import
com.google.appinventor.components.runtime.errors.IllegalArgumentError
;
import
com.google.appinventor.components.runtime.errors.PermissionException
;
import
com.google.appinventor.components.runtime.util.ErrorMessages
;
import
com.google.appinventor.components.runtime.util.FroyoUtil
;
import
com.google.appinventor.components.runtime.util.MediaUtil
;
import
com.google.appinventor.components.runtime.util.SdkLevel
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.media.AudioManager
;
import
android.media.MediaPlayer
;
import
android.media.MediaPlayer.OnCompletionListener
;
import
android.os.Vibrator
;
import
java.io.IOException
;
// TODO: This implementation does nothing about releasing the Media
...
...
@@ -175,8 +174,24 @@ public final class Player extends AndroidNonvisibleComponent
@DesignerProperty
(
editorType
=
PropertyTypeConstants
.
PROPERTY_TYPE_ASSET
,
defaultValue
=
""
)
@SimpleProperty
@UsesPermissions
(
READ_EXTERNAL_STORAGE
)
public
void
Source
(
String
path
)
{
sourcePath
=
(
path
==
null
)
?
""
:
path
;
final
String
tempPath
=
(
path
==
null
)
?
""
:
path
;
if
(
MediaUtil
.
isExternalFile
(
tempPath
)
&&
form
.
isDeniedPermission
(
READ_EXTERNAL_STORAGE
))
{
form
.
askPermission
(
READ_EXTERNAL_STORAGE
,
new
PermissionResultHandler
()
{
@Override
public
void
HandlePermissionResponse
(
String
permission
,
boolean
granted
)
{
if
(
granted
)
{
Player
.
this
.
Source
(
tempPath
);
}
else
{
form
.
dispatchPermissionDeniedEvent
(
Player
.
this
,
"Source"
,
permission
);
}
}
});
return
;
}
sourcePath
=
tempPath
;
// Clear the previous MediaPlayer.
if
(
playerState
==
State
.
PREPARED
||
playerState
==
State
.
PLAYING
||
playerState
==
State
.
PAUSED_BY_USER
)
{
...
...
appinventor/components/src/com/google/appinventor/components/runtime/VideoPlayer.java
View file @
01f7807f
...
...
@@ -6,6 +6,20 @@
package
com.google.appinventor.components.runtime
;
import
static
android
.
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
;
import
android.content.Context
;
import
android.media.AudioManager
;
import
android.media.MediaPlayer
;
import
android.media.MediaPlayer.OnCompletionListener
;
import
android.media.MediaPlayer.OnErrorListener
;
import
android.media.MediaPlayer.OnPreparedListener
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.MediaController
;
import
android.widget.VideoView
;
import
com.google.appinventor.components.annotations.DesignerComponent
;
import
com.google.appinventor.components.annotations.DesignerProperty
;
import
com.google.appinventor.components.annotations.PropertyCategory
;
...
...
@@ -23,20 +37,6 @@ import com.google.appinventor.components.runtime.util.ErrorMessages;
import
com.google.appinventor.components.runtime.util.FullScreenVideoUtil
;
import
com.google.appinventor.components.runtime.util.MediaUtil
;
import
com.google.appinventor.components.runtime.util.SdkLevel
;
import
android.content.Context
;
import
android.media.AudioManager
;
import
android.media.MediaPlayer
;
import
android.media.MediaPlayer.OnCompletionListener
;
import
android.media.MediaPlayer.OnErrorListener
;
import
android.media.MediaPlayer.OnPreparedListener
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.MediaController
;
import
android.widget.VideoView
;
import
java.io.IOException
;
/**
...
...
@@ -193,7 +193,24 @@ public final class VideoPlayer extends AndroidViewComponent implements
description
=
"The \"path\" to the video. Usually, this will be the "
+
"name of the video file, which should be added in the Designer."
,
category
=
PropertyCategory
.
BEHAVIOR
)
@UsesPermissions
(
READ_EXTERNAL_STORAGE
)
public
void
Source
(
String
path
)
{
final
String
tempPath
=
(
path
==
null
)
?
""
:
path
;
if
(
MediaUtil
.
isExternalFile
(
tempPath
)
&&
container
.
$form
().
isDeniedPermission
(
READ_EXTERNAL_STORAGE
))
{
container
.
$form
().
askPermission
(
READ_EXTERNAL_STORAGE
,
new
PermissionResultHandler
()
{
@Override
public
void
HandlePermissionResponse
(
String
permission
,
boolean
granted
)
{
if
(
granted
)
{
VideoPlayer
.
this
.
Source
(
tempPath
);
}
else
{
container
.
$form
().
dispatchPermissionDeniedEvent
(
VideoPlayer
.
this
,
"Source"
,
permission
);
}
}
});
return
;
}
if
(
inFullScreen
)
{
container
.
$form
().
fullScreenVideoAction
(
FullScreenVideoUtil
.
FULLSCREEN_VIDEO_ACTION_SOURCE
,
this
,
path
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment