arabenseifer / google-cast-sdk

Automatically exported from code.google.com/p/google-cast-sdk
0 stars 0 forks source link

MediaInfo.Builder not allowing UNKNOWN_DURATION #471

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Using the MediaInfo.Builder start building a MediaInfo instance...
2. ... try setting the duration (MediaInfo.Builder#setStreamDuration) to 
MediaInfo.UNKNOWN_DURATION

What is the expected output? What do you see instead?
Expected: Let me create a MediaInfo with its stream's duration set to 
UNKNOWN_DURATION (e.g. for STREAM_TYPE_LIVE).
Actual: As stated by its documentation MediaInfo.Builder#setStreamDuration 
throws an exception for negative values, unfortunately UNKNOWN_DURATION is 
"-1". An IllegalArgumentException is thrown.

What version of the product are you using? On what operating system?
com.google.android.gms:play-services:6.5.8 - Android Studio 1.0.2. - Win8.1 x64

Thank you :-)

Original issue reported on code.google.com by hugotheg...@gmail.com on 1 Jan 2015 at 7:23

GoogleCodeExporter commented 9 years ago
You do not need to set the duration; receiver should be able to get the 
duration (from media element, etc) if needed. 

Original comment by anad...@google.com on 2 Jan 2015 at 2:10

GoogleCodeExporter commented 9 years ago
See CastCompanionLibrary for an example use case:

1. A live stream (with duration = UNKOWN_DURATION) is playing on the receiver
2. The sender Android app receives a MediaInfo instance via a RemoteMediaPlayer 
[1]. MediaInfo#getStreamDuration returns UNKOWN_DURATION.
3. This MediaInfo is serialized [2] and messaged to other Activities, 
Fragments, etc. [3]
4. The MediaInfo gets deserialized [4] - for this [5] the MediaInfo.Builder 
prohibits UNKNOWN_DURATION as a valid value for the stream's duration.

I am aware that one (and the CastCompanionLibrary) could work around this 
issue, by only setting the duration field if StreamType != LIVE. Nevertheless I 
still think UNKNOWN_DURATION should be allowed because it is a valid duration 
value.

[1] 
https://github.com/googlecast/CastCompanionLibrary-android/blob/master/src/com/g
oogle/sample/castcompanionlibrary/cast/VideoCastManager.java#L598
[2] 
https://github.com/googlecast/CastCompanionLibrary-android/blob/master/src/com/g
oogle/sample/castcompanionlibrary/utils/Utils.java#L346
[3] 
https://github.com/googlecast/CastCompanionLibrary-android/blob/master/src/com/g
oogle/sample/castcompanionlibrary/cast/VideoCastManager.java#L322
[4] 
https://github.com/googlecast/CastCompanionLibrary-android/blob/master/src/com/g
oogle/sample/castcompanionlibrary/cast/player/VideoCastControllerFragment.java#L
146
[5] 
https://github.com/googlecast/CastCompanionLibrary-android/blob/master/src/com/g
oogle/sample/castcompanionlibrary/utils/Utils.java#L458

Original comment by hugotheg...@gmail.com on 2 Jan 2015 at 2:43

GoogleCodeExporter commented 9 years ago
If you don't know the duration, don't set it.

Original comment by anad...@google.com on 2 Jan 2015 at 3:33